Explain me the use of single quotation and double quotation in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Explain me the use of single quotation and double quotation in python

18th Jan 2020, 4:28 AM
Saurabh Sen
Saurabh Sen - avatar
2 Answers
+ 6
Quotations are used to denote strings. You can use either " ", or ' ' which will do the same thing. String = "test" String = 'test' However here's the trick. Sometimes you may wish to print something like (don't do it). If you were to print('don't do it'), you will get an error because the string will escape the code too early. You will need print("don't do it") to successfully print your message. Another example: print('She said, "How are you"?') You can also use an escape character for complicated scenarios. print('She said, "Don\'t do it" ')
18th Jan 2020, 6:29 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
Please tag 'Python string' 👍
18th Jan 2020, 7:03 AM
Ipang