print(r'He said "i don\'t want to \note" ')

0 Bishwa Nath · April 28, 2015
how to make this work??

print(r'He said "i don\'t want to \note" ')

output needed: 
He said "i dont want to \note"

actual output:
He said "i don\'t want to \note" 

Post a Reply

Replies

Oldest  Newest  Rating
0 Colonel Panic · April 28, 2015
you need the second backslash to show?
0 Colonel Panic · April 28, 2015

>>> print("He said \"i dont't want to note\"")

He said "i dont't want to note"

I can only assume you don't want that second backslash, so here you go.

If you do then

>>> print("He said \"i dont't want to \\note\"")

He said "i dont't want to \note"
+1 K D · April 28, 2015
shouldn't it look like:
print('He said "i don\'t want to \\note" ')
0 Colonel Panic · April 28, 2015
It can work either way.  There are many ways to skin a cat.  Especially with string representation.
  • 1

Python

107,036 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator