Friday, 7 October 2022

Display the numbers and its positions

a=[4,7,3,2,5,9]

for i in a:

    print(str(i)+' is in the position '+ str(a.index(i)+1))


Output:

4 is in the position 1
7 is in the position 2
3 is in the position 3
2 is in the position 4
5 is in the position 5
9 is in the position 6

No comments:

Post a Comment