Answers for "python ennumerate"

5

enumerate python

#Enumerate in python
l1 = ['alu','noodles','vada-pav','bhindi']
for index, item in enumerate(l1):
    if index %2 == 0:
        print(f'jarvin get {item}')
Posted by: Guest on September-03-2020
0

ennumerate python

grocery = ['bread', 'milk', 'butter']

for item in enumerate(grocery):
  print(item)
''' output
(0, 'bread')
(1, 'milk')
(2, 'butter')
'''

for count, item in enumerate(grocery):
  print(count, item)
''' output
0 bread
1 milk
2 butter
'''

# changing default start value
for count, item in enumerate(grocery, 100):
  print(count, item)
''' output
100 bread
101 milk
102 butter
'''
Posted by: Guest on April-27-2021

Python Answers by Framework

Browse Popular Code Answers by Language