enumerate function
l1 = ["potato", "tomato", "egg roll", "chatpati", "rice"]
i = 0
for item in l1:
if i % 2 == 0:
print(f"pls bring this items only {item}")
i += 1
# this is short method of upper code using enumerate function
for index, item in enumerate(l1):
if index % 2 == 0:
print(f"pls bring this item only {item}")
Comments
Post a Comment