Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: fecfb6db94
Fetching contributors…

Cannot retrieve contributors at this time

file 32 lines (26 sloc) 0.955 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
# Extra credit #1: The other escape squences
# are found here: http://docs.python.org/reference/lexical_analysis.html

tabby_cat = "\tI'm tabbed in."
persian_cat = "I'm split\non a line."
backslash_cat = "I'm \\ a \\ cat."

# Extra credit #2 asks to try replacing """ with '''. I guess if you
# needed to use """ in your string block somewhere, that would be
# useful to replace.
fat_cat = '''
I'll do a list:
\t* Cat food
\t* Fishies
\t* Catnip\n\t* Grass
'''

print tabby_cat
print persian_cat
print backslash_cat
print fat_cat

# Extra credit #3 wants me to combine escape characters and format
# string to create something more complex... here goes...

crazy_cat = "\t%s %s \n%s %s \\%s"
print crazy_cat % ("I'm", 'a', 'fucking', 'crazy', 'cat')

# Extra credit #4 asks me to replace %s with %r to see what happens.
# It causes the quotes to be printed out.
crazy_cat = "\t%r %r \n%r %r \\%r"
print crazy_cat % ("I'm", 'a', 'fucking', 'crazy', 'cat')
Something went wrong with that request. Please try again.