' " or nothing in Python | SoloLearn: Learn to code for FREE!

+2

' " or nothing in Python

How do you know if you're supposed to use ' " or nothing to surround text in Python?

6/24/2018 1:01:16 PM

Alisse Canre

3 Answers

New Answer

+2

You need ' or " to make a string. What you use is a matter of style or convention both will work, just use them consistenly. ("this' is no good) I think mostly " are used for strings that represent sentences in human language like "hello world" and ' are used for more abstract strings like single charaters etc.

+2

Text (strings) are always inside " or '. But make sure to use the same one as the start and end! "String"

+1

You can use single or double inverted comma's to create string .but if you want to do tricks with your String then you can try both. e.g= x=('"Hi"') print(x) output="Hi" because "" is also a string here.