hello I'm learning python. I want to use Quote from person in my Sentence but I see this Error. How can I solve it? I write my code down line:
sentence='shiva said:'I am\n programmer''
print(sentence)
and my Error is: invalid syntax
hello I'm learning python. I want to use Quote from person in my Sentence but I see this Error. How can I solve it? I write my code down line:
sentence='shiva said:'I am\n programmer''
print(sentence)
and my Error is: invalid syntax
Strings in Python can use double quotes or single quotes. If you want single quotes in the sentence you can use double quotes:
sentence = "shiva said:'I am\n programmer'"
You can also just escape the single quotes by preceding with a backslash. This tells Python to not treat the following single quote as the end of the string.
sentence = 'shiva said:\'I am\n programmer\''
Triple quotes are also available (both types) and can span multiple lines:
sentence = """shiva said 'I am
programmer'"""