[Tutor] Tutor Digest, Vol 103, Issue 82
Dave Angel
d at davea.name
Tue Sep 18 00:11:44 CEST 2012
On 09/17/2012 05:24 PM, Aaron Pilgrim wrote:
Why are you replying to a digest? Reply to one of the messages on the
thread you're responding to, and it'll get the subject line right.
It'll also thread it together.
>> Message: 7
>> Date: Mon, 17 Sep 2012 21:34:05 +0530
>> From: Santosh Kumar <sntshkmr60 at gmail.com>
>> To: tutor <tutor at python.org>
>> Subject: [Tutor] Trying to get next item from a list
>> Message-ID:
>> <CAE7MaQZ6XO_YHc4gTF16mMVxn2dAF+ZSAoUpGft21d2G-Q52Hg at 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()
What makes you think lower() doesn't work? You haven't used it yet. Try
i = 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])
>
--
DaveA
More information about the Tutor
mailing list