33 lines
739 B
Python
33 lines
739 B
Python
|
|
# https://www.w3schools.com/python/python_ref_list.asp
|
|
# https://www.quackit.com/python/reference/python_3_list_methods.cfm
|
|
|
|
programMessage = '''
|
|
The count() method counts the number of elements in a list.
|
|
|
|
'''
|
|
|
|
print(programMessage)
|
|
|
|
|
|
basicList = [1, 34, 99, 87, 14, 1, 34, 1,87 ]
|
|
print(f"Example list {basicList}")
|
|
|
|
myValue = 1
|
|
counter = basicList.count(myValue)
|
|
print(f"The number of '{myValue}' items is {counter}")
|
|
|
|
myValue = 34
|
|
counter = basicList.count(myValue)
|
|
print(f"The number of '{myValue}' items is {counter}")
|
|
|
|
myValue = 87
|
|
counter = basicList.count(myValue)
|
|
print(f"The number of '{myValue}' items is {counter}")
|
|
|
|
myValue = 314
|
|
counter = basicList.count(myValue)
|
|
print(f"The number of '{myValue}' items is {counter}")
|
|
|
|
|
|
|