On 3/21/11, David <[email protected]> wrote: > 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. No, the function takes a letter and returns that letter in its uppercase form. lr="a" lr.upper() #lr now = A lr.lower() #lr now equals a I should actually say that it takes a string and uppercases any letters in it. It just happens that you are dealing with one letter here. > > 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 > _______________________________________________ > Tutor maillist - [email protected] > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor >
-- Have a great day, Alex (msg sent from GMail website) [email protected]; http://www.facebook.com/mehgcap _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
