How to Assign a Multiline String to a Variable in Python


In this example we will show how to assign a multiline string to a variable using three double quotes in Python.

Source Code

my_str = """Python is an easy to learn, 
powerful programming language. 
It has efficient high-level data structures 
and a simple but effective approach to 
object-oriented programming."""

print(my_str)

Output:

Python is an easy to learn, 
powerful programming language. 
It has efficient high-level data structures 
and a simple but effective approach to 
object-oriented programming.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

How to Assign a Multiline String to a Variable in Python


In this example we will show how to assign a multiline string to a variable using three single quotes in Python.

Source Code

my_str = '''Python is an easy to learn, 
powerful programming language. 
It has efficient high-level data structures 
and a simple but effective approach to 
object-oriented programming.'''

print(my_str)

Output:

Python is an easy to learn, 
powerful programming language. 
It has efficient high-level data structures 
and a simple but effective approach to 
object-oriented programming.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments