Text Concatenation
So far, we have printed each text on a new line. What if we want to concatenate text and print it on one line? We can achieve this using the +
operator. For example:
day = "Saturday"
print("Today is " + day + ".")
This will print:
Today is Saturday.
We most often use text concatenation when we want to insert the value of a variable (or multiple variables) into the text.
Instructions
Print John Doe
using the print
statement with the variables first_name
and last_name
.
Hint: insert " "
between first_name
and last_name
.
Start programming for free
6/10