Mix Words and Numbers
Learn how to combine variables and text in print messages.
We'll cover the following...
We'll cover the following...
Now that Python can remember things, let’s make our messages more dynamic!
This lesson will teach us how to combine words and numbers to create full sentences using variables.
Mix it up
Try this code:
Awesome! We just combined strings and numbers in one line.
Why commas?
In print(), commas separate each part of our message. Python puts them together and even adds spaces for us.
We can mix:
Strings (text in quotes)
Variables (like
name,age)Numbers
All in a single print() statement.
Your turn: Build a fun message
Now swap in your own favorite things!
We just made a custom sentence using commas.