python3 enumerate code example
Example 1: enumerate in python
languages = ['Python', 'C', 'C++', 'C#', 'Java']
i = 0
for language in languages:
print(i, language)
i+=1
for i, language in enumerate(languages):
print(i, language)
Example 2: enumerate python
for index,subj in enumerate(subjects):
print(index,subj)
0 Statistics
1 Artificial intelligence
2 Biology
3 Commerce
4 Science
5 Maths
Example 3: enumerate python
l1 = ['alu','noodles','vada-pav','bhindi']
for index, item in enumerate(l1):
if index %2 == 0:
print(f'jarvin get {item}')
Example 4: python3 any
l = [1, 3, 4, 0]
print(any(l))
l = [0, False]
print(any(l))
l = [0, False, 5]
print(any(l))
l = []
print(any(l))