How to count elements in a list python

2 Answers

0 votes
lst = [1, 2, 3, 7, 8, 'python']

print(len(lst))
 
 
 
 
'''
run:
 
6
 
'''

 



answered Apr 30, 2021 by avibootz
0 votes
def total_elements(lst):
    count = 0
    for element in lst:
        count += 1
    return count
    
lst = [1, 2, 3, 7, 8, 'python']    

print(total_elements(lst))
 
 
 
 
'''
run:
 
6
 
'''

 



answered Apr 30, 2021 by avibootz
...