0
0
Pythonprogramming~15 mins

Writing multiple lines in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Writing Multiple Lines in Python
📖 Scenario: Imagine you want to write a short note with multiple lines to share with a friend. You will learn how to create and print multiple lines of text in Python.
🎯 Goal: You will build a small program that stores a three-line message and prints it exactly as written, with each line on its own line.
📋 What You'll Learn
Create a variable called message that holds three lines of text exactly as given.
Use triple quotes to write the multiple lines inside message.
Create a variable called separator that holds a string of three dashes ---.
Print the message variable.
Print the separator variable.
💡 Why This Matters
🌍 Real World
Writing multi-line text is useful for creating messages, letters, or formatted output in programs.
💼 Career
Understanding how to handle multi-line strings helps in many programming tasks like generating reports, emails, or documentation.
Progress0 / 4 steps
1
Create the multi-line message
Create a variable called message that holds the following three lines exactly using triple quotes:
Hello, friend!
Welcome to learning Python.
Let's write multiple lines.
Python
Need a hint?

Use triple single quotes ''' or triple double quotes """ to write multiple lines inside one string.

2
Add a separator line
Create a variable called separator and set it to the string --- (three dashes).
Python
Need a hint?

Just assign the string '---' to the variable separator.

3
Print the message
Use print(message) to display the multi-line message stored in the variable message.
Python
Need a hint?

Use the print function with the variable message inside the parentheses.

4
Print the separator
Use print(separator) to display the separator line stored in the variable separator.
Python
Need a hint?

Use the print function with the variable separator to show the dashes after the message.