0
Error for: ('I'm leaving!') Why?
Contractions
10 Answers
+ 5
The other ways to put quotes in quotes, are:
+ 'escape' them (meaning warn Python that you put a quote inside the string literal, and that's not the closing quote marking the end of the string):
print('I\'m leaving')
the backslash (\) say to Python that next char is in string and not to be interpreted... So, to put backslash in a string literal, you need to escape it if just before an escapable char ^^
print('I\'m a backslash: \\')
this work same for double quotes strings...
+ use triple quote (simple or double) notation, which allow also multilines strings (the only place were you cannot put same type of quote is just before ending triple quotes, as Python interpreter will considerate the first 3 as the 3 closing -- same limitation with backslash, but simple workaround by inserting a space at end of string before the closing quote(s) ^^)
print('''This is a simple quote which doesn't need to be escaped...''')
+ 3
You have the answer already but for the sake redundancy I'll tell you why it didn't work initially.
Python is confused why you have 3 single quotes when it expected 2. That's because of the apostrophe in I'm.
To fix this you either need to make the outside single quotes into double quotes ("...") or to keep everything the same except for I'm which you can fix by writing I\'m instead
+ 2
What's the error? Maybe its the quotes, have you tried:
("I'm leaving!")
+ 2
Ahh, that makes sense. Still new. I appreciate the help, being the newbie.
+ 1
Could very well be. Those pesky inverted commas catch me out from time to time.
+ 1
No problemo.
+ 1
Put it way better than I could. Spot on, Usopp.
0
I have not used quotes. I assumed the 'I'm' is the error in question.
0
The quotes seem to work. I have much to learn. Thank you so much!
0
Oh wow, Visph. I have so much to learn. Thank you (and God Usopp and Bashot) for giving me so much to play with here! I can\'t wait to keep devouring more info!!!