What is the difference between using single, double, and triple quotes?


What is the difference between using single quotes ('), double quotes ("), and triple quotes (""") for strings?


Using single and double quotes are equivalent. The only difference is when we use an apostrophe or additional quotation marks inside the string, in which case we may need to escape those punctuation(s) using a backslash (\). For example:

print("That's great!")
print('That\'s great!')

Triple quotes, on the other hand, are used for multi-line strings as well as docstrings.

1 Like