sep 15
Next assignment is posted: due Tue through the end of chapter 4 on strings.
Finish discussion of strings and write in class a rot13 program; see
sep 13 notes.
# rot13.py
# Example of rot13 text transform
# Jim M , Sep 16 2010 (in class)
#
import string
def main():
# 1. Get the text to be transformed.
text = raw_input("What is the (lowercase) word? ")
# 2. Convert the text to rot13.
rot13_text = ""
for char in text:
number = ord(char) - ord('a')
# print " debug: number = ", number
rot13_number = (number + 13) % 26
# print " debug: rot13_number + ", rot13_number
new_char = chr(rot13_number + ord('a'))
# print " debug: new_char = '%s' " % new_char
rot13_text = rot13_text + new_char
# 3. Output the text.
print "rot13='%s'" % rot13_text
main()