-4

How can I type “” in string.like he said “felt not well.” But it show error. How can I type “” in string python ? I tried so many method can’t make it.

Kai Long
  • 15
  • 5

3 Answers3

0

You need to escape your special characters like " or ' by putting a backslash before it like so:

myString = "he said \"felt not well\""
Max7cd
  • 94
  • 6
0

You can either use ' outside the string:

s = 'he said "felt not well"'

or use a triple ":

s = """
    he said "felt not well"
    """

or escape each character:

s = "he said \"felt not well\""
Merig
  • 1,751
  • 2
  • 13
  • 18
0

You can use Unicode characters. For example like this:

print(u'\u201CHallo World\u201D')

This will result in “Hallo World”

If you just want to add regular " You can either use different quitations print('"Hello World"') this will print "Hello World"

Or you can use escaping print("\"Hello World\"") this will print "Hello World"

Vulpex
  • 1,041
  • 8
  • 19