Example 1: count similar values in list python
MyList = ["a", "b", "a", "c", "c", "a", "c"]
return my_dict = {i:MyList.count(i) for i in MyList}
{'a': 3, 'c': 3, 'b': 1}
from collections import Counter
return my_dict = dict(Counter(MyList))
{'a': 3, 'c': 3, 'b': 1}
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))
Example 4: how to find the amount of numbers in a list on python
>>> someList=[]
>>> print len(someList)
0
Example 5: number of elements in list in python
listOfElems = ['Hello', 'Ok', 'is', 'Ok', 'test', 'this', 'is', 'a', 'test']
len(s)
Example 6: how to find length of list python
my_list = [1,2,3,4,5,6,7,8,9,10]
length_of_list = len(my_list)