Exploring String Delimiters


Delimiters are the characters that start and stop a certain part of code.

Strings, or groups of characters, can be delimited in 4 ways in Python:

'Single Quotes' (apostrophe)

"Double Quotes" (quotation marks)

'''Triple Single Quotes''' (multi-line strings)

"""Triple Double Quotes""" (multi-line strings)

Each of these strings is the same in the memory of Python interpreter but:

Multi-line strings are easiest to code with the multi-line delimiters:

print("First line,

second line,

third line,


Will print:

First line,

second line

third line,


It's not so important when TO use each, but more important when NOT to use each.

For instance, if you need an ' in your output, it's simple to use " for a delimiter:

print("It's mine.")

Or if you need " in your output, use ':

print('The cat said, "meow"')

But trouble ensues if you need both in your string such as printing the phrase:

He said, "It's your fault."

You could accomplish this with triple-single quotes:

print('''He said, "It's your fault."''')

or using Escape Characters (special sequences of characters to print single characters)

print("He said, \"It's your fault\"")

For instance notice the \" in code prints " in output.

Next Post: Who is "You" Revisited

Recent Posts