-1

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

PM 77-1
  • 12,933
  • 21
  • 68
  • 111

3 Answers3

2

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:

Jordan
  • 540
  • 4
  • 10
1

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")

0

"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}")
Alexander L. Hayes
  • 3,892
  • 4
  • 13
  • 34
MOHANISH
  • 11
  • 1
  • 3
    The commas are part of the syntax of the call to `print`, nothing to do with constructing a single string. – chepner Dec 08 '22 at 17:07