fb pixel

String variables and operations

So far we have done manipulations with numeric values but python provides many utilities to deal with textual values (strings) as well.
We can add two strings together, which will concatenate those two texts together. We can multiply a string by a number n, which will repeat that string n times, etc.
s1 = 'Hello world!'
s2 = 'My name is Anna'
s3 = s1 + s2
print(s3)       # Hello world!My name is Anna
print(s1 + s2)  # Hello world!My name is Anna
print(s1 * 3)   # Hello world!Hello world!Hello world!
print(s2 + '!') # My name is Anna!

Challenge

Given two strings in the input, create a third one called total, which contains the two separated by a space, and print total in the output.
Input
Output
Hello My name is Bob
Hello My name is Bob
 
To check your solution you need to sign in
Sign in to continue