> ################################## > ## rot1: char -> char > ## Rotates a single character. > 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)
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. The bug is in the definition and use of 'test'. Not only is the variable name somewhat undescriptive, but it's only being defined in only one branch of the conditional. That's a "bad" code smell, and in this case, you'll find an issue here when trying to rotate a non-alphabetic character. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor