All lessons

Working with Text

7 min · Python

Join text together, measure it, and change its case.

Text values are called strings — just characters inside quotes. You can join two strings with a plus sign. That joining is called concatenation.

Run this to glue a greeting and a name into one line.

Try it yourself

Loading editor...

Ln 1, Col 1Spaces: 4
Sign up to run itExpected output: Hello, Ada

f-strings: drop values straight into text

Joining with + gets clumsy fast. A cleaner way is an f-string: put the letter f before the opening quote, then wrap any variable in { } right inside the text.

Try it yourself

Loading editor...

Ln 1, Col 1Spaces: 4
Sign up to run itExpected output: Ada is 36 years old

Useful string tools

len(x) tells you how many characters a string has. And .upper() / .lower() give you a new copy in upper- or lower-case.

Try it yourself

Loading editor...

Ln 1, Col 1Spaces: 4
Sign up to run itExpected output: 6 PYTHON

Your turn

Set first = "Grace" and last = "Hopper", then print them as one name with a space between: Grace Hopper

Your turn

Loading editor...

Ln 1, Col 1Spaces: 4