How to count number of items in list python
Today we will talk about the new function of the list, which many programmers are still unfamiliar with. In this tutorial, we will see in our website kodlogs what the function of the list count works in Python. Like all of you programming learners.
Students have learned how easy Python is compared to other programming languages. It has functions that are known by their own name. As their name , so does their work. If any English. If he is very good at learning or speaking, he can understand Python quickly. Python is so easy that you can learn it in 3 months. Even boys in the tenth grade can learn Our topic is how to count the number of item in list python. This question states that if you calculate the value in the list in Python, then we can solve it by using a simple function count. It also helps us to know where the store is in the index. If we have 5 elements in the list, the first element starts with 0 and ends with the last _1.
You may have read about arrays in other programming languages. The list is exactly the same. We can store different data types in the list. We don't need a lot of variables separately. The list helps us to store more values. We can store many atoms and values together in the list. The list uses a square bracket with a comma.
# vowels list
vowels = ['a', 'e', 'i', 'o', 'i', 'u']
# count element 'i'
count = vowels.count('o')
# print count
print('The count of i is:', count)
# count element 'p'
count = vowels.count('T')
# print count
print('The count of p is:', count)
The count of i is: 3
The count of p is: 0