First of all, I'm not a native English speaker so I hope I can express my problem.
I want to know if an element is in some specific list's 2nd, 4th, 6th... index.
I want to check it like this: (This wont work obvioulsy...)
if a in list1[2n]:
print(list1[2n-1])
Shortly, my aim is printing previous element of that list if selected element is in an even number index and doing nothing if it is in an odd number. How to do this?
Aucun commentaire:
Enregistrer un commentaire