Thursday 23 September 2021

Python: Define multi line strings

By enclosing the string in three quotes, we can define multi line strings.

 

Example

str1 = '''Hello world
How are you
I am fine, what about you
I am good, thank you....'''

		(OR)

str2 = """Hello world
How are you
I am fine, what about you
I am good, thank you...."""

 

multi_line_strings.py

str1 = '''Hello world
How are you
I am fine, what about you
I am good, thank you....'''

str2 = """Hello world
How are you
I am fine, what about you
I am good, thank you...."""

print(str1)
print('\n\n')
print(str2)

 

Output

Hello world
How are you
I am fine, what about you
I am good, thank you....



Hello world
How are you
I am fine, what about you
I am good, thank you....

 

 

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment