Python List: count

count(value)
  • Returns the number of times a value appears in the list.

Return Type:

  • integer
value:
  • value that was added to the python list.
  • Type:  same as list.  Boolean or string or integer or etc.
Sample Code

################## add a value to the list
  

# import bge
import bge

# get the current controller
cont = bge.logic.getCurrentController()

# get the object the controller is attached to
obj = cont.owner

# obj["lap_times"] is a python list I created

# get the number of times 215 is in list
obj["lap_times"].count(215)