Step Three: Escape!
Don't get too comfortable: you can't use justany symbol in a string, and some results can only be achieved by special characters. The practice of including these characters in a string requires that these strings beescaped, or marked as unique. The backslash character (\
) does this work for us! We just put it directly before the character we want to escape.
The string in the editor is broken: the apostrophe in I'm
makes Python think the single-quote string ends there. Fix it by escaping the '
in I'm
!
# The string below is broken. Fix it using the escape backslash!
s="Help! Help! I'm being repressed!"
print s
s='Help! Help! I\'m being repressed!'
print s