2021年5月1日星期六

Python3 : How to Use enumerate() to Print total items in a list?

Instead of using len, i am using enumerate function. In it, how can i get total number of items?

Sample code:-

data = ['bat','cat','eat','fat','தொப்பி','எலி']  for itemNum, item in enumerate(data):      print(itemNum+1, end='')  

result: 123456

expected result: 6

https://stackoverflow.com/questions/67345588/python3-how-to-use-enumerate-to-print-total-items-in-a-list May 01, 2021 at 07:10PM

没有评论:

发表评论