String Concatenation
You know about strings, and you know about arithmetic operators. But did you know some arithmetic operators work on strings?
If you use the +
operator between two strings, it concatenates them (glues them together).
print "Monty " + "Python"
will print out "Monty Python"
!
Give it a go in the editor. print
the concatenated strings "Spam "
, "and "
, "eggs"
on line 3 to print the string"Spam and eggs"
to the console.