[Tutor] Trying to get next item from a list
tvssarma.omega9 at gmail.com
Mon Sep 17 18:18:06 CEST 2012
On 17 September 2012 12:04, Santosh Kumar <sntshkmr60 at gmail.com> wrote:
> 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',
> i = input("Press any English alphabet: ")
> current = alphabets.index(i)
> next = current+1
> 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?
When you access index the second time you are trying to do so with the
value of the index.
0 1 0
0 0 1
1 1 1
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor