> Message: 7 > Date: Mon, 17 Sep 2012 21:34:05 +0530 > From: Santosh Kumar <sntshkm...@gmail.com> > To: tutor <tutor@python.org> > Subject: [Tutor] Trying to get next item from a list > Message-ID: > <cae7maqz6xo_yhc4gtf16mmvxn2daf+zsaoupgft21d2g-q5...@mail.gmail.com> > Content-Type: text/plain; charset=UTF-8 > > 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? > > > ------------------------------
Hello, I am new to python. Here is what I wrote. my lower() function does not work and it can not take capital letters. def func3(): 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: ") i.strip().lower() current = alphabets.index(i) print("current index value: ", current) next = (current + 1) % 26 print("next index value: ", next) print("The next letter is...", alphabets[next]) _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor