Python Program to Create a Long Multiline String

 

Example 1: Using triple quotes

my_string = '''The only way to
learn to program is
by writing code.'''

print(my_string)

Example 2: Using parentheses and a single/double quotes

my_string = ("The only way to \n"
        "learn to program is \n"
        "by writing code.")

print(my_string)

Example 3: Using \

my_string = "The only way to \n" \
        "learn to program is \n" \
        "by writing code."

print(my_string)

0 Comments