Python: 03 Strings are Text

Strings are a data type that is used to store text.

Any data the has characters (A-Z, a-z and other symbols like ! @ ‘ , . &) is a string, if it also has characters and numbers it will be stored as a string.

If it just has numbers it will be stored as a number.

It is really important to know what type of data you want to store.

Strings are always enclosed in a pair of ” ” or ‘ ‘

If you are going to have a ‘ in the text such as in don’t use the ” ” to enclose the string.

"In time they're going to be ok"

It is a good habit to be consistent with that you use to enclose the string.

You can write a multiple line string by enclosing it with “”” “”

"""Hello,
This string contains text that
is spread over
multiple
lines."""

The more you comment your code the easier it is to understand and maintain.

You might remember what you are working on right now, but what happens when someone else looks at your code or you come back to it a week, month or a year later?

You might also like