#You will get an error if you use double quotes inside a string
#that is surrounded by double quotes:
txt = "We are the so-called "Vikings" from the north."
#To fix this problem, use the escape character ":
txt = "We are the so-called "Vikings" from the north."
#Output: We are the so-called "Vikings" from the north.
Please thank, like, use in you code and improve!!!
#Enclosing quotes with qoutes of the same kind terminates the string prematurely.
#Hence, escape such errors using the escape character(backslash).
word = ""I am a boy", he said."# Terminates the string prematurely.
#Outputs , he said.
word = ""I am a boy", he said"
print(word)# Outputs "I am a boy, he said.
Types of escape characters:
- newline - tab spacing
- carriage return
creates a backslash since one backslash is used to escape
#However using different quotes does no damage to the code.
word = '"I am a boy", he said.'
#Outputs "I am a boy", he said.
I hope I've helped you guys understand the topic better.
Bye, see you soon!!!
>>> spam = 'Say hi to Bob's mother.'