2

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

3 Answers 3

1
print ('Hello ' + name + '!' *3)
Sign up to request clarification or add additional context in comments.

Comments

0

Its as simple as adding a space withing the quotes. The interpreter prints what is directly given in the quotes.

print ('Hello ' + name + '!' *3)

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.