Escape Characters (Double Quotes inside String) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Escape Characters (Double Quotes inside String)

I know that to escape a double quote in a string. But when I was giving an example, I tried to show how to do the escape characters, meaning I tried to output my code as \“Hello\“ keep in mind that is supposed to be my output, not the code I am programming, But I cannot put \\”Hello\\” in my line of code, how do I get behind that? Also keep in mind I’m a BEGINNER, so please don’t make it too complicated, thank you.

23rd Sep 2018, 5:51 PM
Quan Huynh
Quan Huynh - avatar
4 Answers
+ 14
print(r'\"Hello\"') print('\\"Hello\\"') print("\\\"Hello\\\"")
23rd Sep 2018, 5:54 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 3
Saurabh Sharma they all print the same thing but first one looks better in my opinion
24th Sep 2018, 1:34 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 2
Thanks!
23rd Sep 2018, 5:56 PM
Quan Huynh
Quan Huynh - avatar
+ 1
hello Mert which one is right ?
24th Sep 2018, 10:15 AM
Saurabh Sharma