Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Multiline Strings | Basic Concepts
String Manipulation in Python

Glissez pour afficher le menu

book
Multiline Strings

What if we want to store some large text into one variable? By using large comparison, I mean text in multiple lines.

Fortunately, Python allows us to save multiple lines as one string. To do it, use tripled quotation marks. For example,

12345
# Creating three-lines string large_string = """Course: String Manipulation in Python Technology: Python Level: Beginner""" print(large_string)
copy

Note

Like in the previous chapter, you have to use the same quotation marks type (i.e. only single or double).

Tâche

Swipe to start coding

Assign to variable courses the following string (contains of 2 rows):

Introduction to Python

String Manipulation in Python

Then print this string into console.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 2
Nous sommes désolés de vous informer que quelque chose s'est mal passé. Qu'est-il arrivé ?

Demandez à l'IA

expand
ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

book
Multiline Strings

What if we want to store some large text into one variable? By using large comparison, I mean text in multiple lines.

Fortunately, Python allows us to save multiple lines as one string. To do it, use tripled quotation marks. For example,

12345
# Creating three-lines string large_string = """Course: String Manipulation in Python Technology: Python Level: Beginner""" print(large_string)
copy

Note

Like in the previous chapter, you have to use the same quotation marks type (i.e. only single or double).

Tâche

Swipe to start coding

Assign to variable courses the following string (contains of 2 rows):

Introduction to Python

String Manipulation in Python

Then print this string into console.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 2
Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Nous sommes désolés de vous informer que quelque chose s'est mal passé. Qu'est-il arrivé ?
some-alt