I added an operators to give spaces between the two strings but it still doesn't work

119 Views Asked by At

I was trying to make a name input that whenever you type a name it places on the welcome sign of the game. The only problem I am experiencing is that the name I input never has spaces between it, despite that I placed an operator to give it a space

name = input("what is your name:")
print("Welcome to the Casino" + name + "now go play till get broke")

and this is the output result: Welcome to the CasinoMikenow go play till get broke

3

There are 3 best solutions below

0
Jordan On

You could always just add a space after 'Casino' and before 'now'. A better way would be to use an fstring.

For example:

name = input("what is your name: ")
print(f'Welcome to the Casino {name} now go play till get broke')

Output:

what is your name: Jordan
Welcome to the Casino Jordan now go play till get broke

Edit: Here are a few resources on format string literals:

1
MOHANISH On

"Welcome to the casino " + name + " now go play"

type it like this add a space at the end

Or just

name = input("what is your name: ")
print(f"Welcome to the Casino {name}")
0
Akshat Gupta On

Their are many ways to solve this problem for example:

  1. You can add space after the word "Casino" and before the word "now"

    print("Welcome to the Casino" + name + "now go play till get broke")

  2. You can use "," instead of using "+" to separate multiple values in print statement:

    print("Welcome to the Casino", name, "now go play till get broke")