String Concatenation
Learn how to join strings together in Python, handle spaces, and include numbers in text safely.
Sounds useful?
Jump into the interactive version.
No setup. No account. Just Python.
String Concatenation
Learn how to join strings together in Python, handle spaces, and include numbers in text safely.
Jump into the interactive version.
No setup. No account. Just Python.
This Block teaches one of the most common text-building basics in Python: joining strings together with +. You will start with tiny examples like combining a first name and last name, then move into building full messages, sentence pieces, profile text, and receipt-style strings.
You will also learn the sneaky parts: Python does not add spaces for you, quoted variable names are just text, and joining strings with numbers requires converting the number first with str().
What you will learn:
+"2" + "3" becomes "23", not 5str() to include numbers inside textBy the end, you will be able to build clear text messages from smaller values and understand exactly what Python is doing when it glues strings together.
Ready to practice this in the browser?
> Play now