Python - Strings
Code Life
By Pierre Marsaa
Intro to Strings
Short intro
This lesson is a short introduction to strings. There is a chapter for them later in the course, but I wanted to introduce them here like all the other data types.
Strings are types of data in Python. They can be created using either single quotes (' ') or double quotes (" "). In it, you can basically write anything you want.
↗️
Loading editor...
↶
↷
When do we use strings?
Strings are used to represent text data. They can be used for names, messages, or any other textual information. Strings are also used to format output, such as displaying messages to users.
Don't use string when not needed
The trap with strings is that you can use them to represent anything, but you should not. For example, if you want to represent a number, use an integer or a float. Don't create something like this: level = '20' because you will not be able to use it as a number.
Verify