Reputation: 23
I've just started learning Python 3 - and programming in general - and can't figure out how to put a space between Hello and a variable.
name = Amy
print ('Hello' + name + '!' *3)
That prints out as HelloAmy!!! How do you put a space between Hello and Amy?
Thanks
Upvotes: 2
Views: 229
Reputation: 519
Its as simple as adding a space withing the quotes. The interpreter prints what is directly given in the quotes.
print ('Hello ' + name + '!' *3)
Upvotes: 0
Reputation: 45736
Just add a space in the existing string:
name = 'Amy'
print ('Hello ' + name + ('!' * 3))
# ^ Space
or if 'Hello'
was defined by another variable, you could have just added another string containing only a space:
print (hello_string + ' ' + name + ('!' * 3))
I assuming Amy
should have been in quotes
Upvotes: 0