[Tutor] a function I fail to understand
David
ldl08 at gmx.net
Tue Mar 22 02:06:21 CET 2011
Hello list,
I am having trouble understanding the following function. What trips me
up is the "letter = letter.lower()" line.
As I understand, the function takes a letter and assigns True to a
letter if it is upper case.
But then he goes to
letter = letter.lower()
and all letters are converted back to lower again!?? The point is that,
to my understanding, the logic follows from the first block to
letter = letter.lower(). Isn't that true?
Thanks for helping me out,
David
def rotate13_letter(letter):
"""
Return the 13-char rotation of a letter.
"""
do_upper = False
if letter.isupper():
do_upper = True
letter = letter.lower()
if letter not in CHAR_MAP:
return letter
else:
letter = CHAR_MAP[letter]
if do_upper:
letter = letter.upper()
return letter
More information about the Tutor
mailing list