learnpython.org - an online interactive Python tutorial

rantingrick rantingrick at gmail.com
Sat Apr 23 11:16:14 EDT 2011


On Apr 23, 1:28 am, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:

> But what if /I/ want
>                 "A" + 1
> to return
>                 "B"


No problem! Python even allows you to create your own functions! I
know, amazing! 8-O

>>> def succ(s):
	return chr(ord(s) + 1)

>>> succ('a')
'b'
>>> succ('B')
'C'
>>> succ('Z')
'['

PS: The cases of (s > 255) or (s < 0) will be for the advanced reader
to solve.



More information about the Python-list mailing list