Printing specific elements from a list
The following program will print the 1st, 3rd and 5th elements of the list only.
list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for index, item in enumerate(list):
if index==0 or index==2 or index==4:
print(index, item)
Comments
Post a Comment
Write something to CodeWithAbdur!