List provides
count method, to count number of times element appear in the result.
test.py
list=[12, 5, 32, 43, 21, 356, 5, 21] print(list) print("5 appears ",list.count(5)," times") print("12 appears ",list.count(12)," times")
$ python3
test.py
[12, 5, 32,
43, 21, 356, 5, 21]
5
appears 2 times
12 appears 1
times
No comments:
Post a Comment