Skip to Content
Strings & Console Output
String Concatenation

You know about strings, and you know about arithmetic operators. Now let’s combine the two!

print "Life " + "of " + "Brian"

This will print out the phrase Life of Brian.

The + operator between strings will ‘add’ them together, one after the other. Notice that there are spaces inside the quotation marks after Life and of so that we can make the combined string look like 3 words.

Combining strings together like this is called concatenation. Let’s try concatenating a few strings together now!



Let’s give it a try. Print the concatenated strings "Spam ", "and ", "eggs" on line 3, just like the example above.

Make sure you include the spaces at the end of "Spam " and "and ".

Folder Icon

Take this course for free

Already have an account?