get number of items in list python code example

Example 1: get list number python

my_list = [1,"hello world", 16.2]
len(my_list)
3

Example 2: python find the number of elements in a list

list1 = [2,3,4,3,10,3,5,6,3]
elm_count = list1.count(3)
print('The count of element: 3 is ', elm_count)

Example 3: python how to count all elements in a list

List = ["Elephant", "Snake", "Penguin"]

print(len(List))

#	With the 'len' function Python counts the amount of elements 
#	in a list (The length of the list).
#	In this case the output is '3' because there are 3 elements in the list.

Example 4: how to find the amount of numbers in a list on python

>>> someList=[]
>>> print len(someList)
0

Example 5: length of list python

thistuple = ("apple", "banana", "cherry")
print(len(thistuple))

Example 6: how to count things in a list python

list.count(element)

list1 = ['red', 'green', 'blue', 'orange', 'green', 'gray', 'green']
color_count = list1.count('green')
print('The count of color: green is ', color_count)

Tags:

Cpp Example