I am trying to find out the position of a certain element in a list. In concept, I input an item in the list, and it should return the position of that item. I have written this:
alphabet = ["a", "b", "c", "d", "e"]
letter = "d" #Want the position in the list of this letter.
for i in range(0, len(alphabet)):
if alphabet[i] == letter:
position = i
break
which works, but I feel like there is a more elegant/efficient way of doing it. Any suggestions would be appreciated!