[Tutor] Trying to get next item from a list

Santosh Kumar sntshkmr60 at gmail.com
Mon Sep 17 18:04:05 CEST 2012


Here is the script:

alphabets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
'z']
i = input("Press any English alphabet: ")
current = alphabets.index(i)
print(current)
next = current+1
print(next)
print(alphabets.index(next))

I am getting a ValueError.

And as you can see, I just trying to get the next item. So is there
any way I can get same functionality in less line of codes?


More information about the Tutor mailing list