[Tutor] implementing rot 13 problems
Danny Yoo
dyoo at hashcollision.org
Tue Mar 12 20:18:52 CET 2013
> Also note that I've deliberately left alone a bug in rot1(), to make
> it easier to show a flaw in the original code that you'll want to fix.
Doh. Never mind. _I'm_ the one who introduced that regression. :( Sorry!
Here's a corrected definition for rot1():
#############################
def rot1(char):
if char.isupper() or char.islower():
test = 'M' if char.isupper() else 'm'
if char <= test:
return chr(ord(char) + 13)
else:
return chr(ord(char) - 13)
else:
return char
#############################
My apologies!
More information about the Tutor
mailing list