0

User name input

When I use the code: x = input("John") print("Welcome" + x) I get an output of... JohnWelcome ...Instead of an expected "Welcome John" What on earth is going on here?

20th Dec 2022, 2:06 AM
Ambrose Ling
Ambrose Ling - avatar
3 odpowiedzi
+ 2
Hello. The input() Syntax is: input(prompt) The input() function allows user input. When you put a string value in the input() for example: input("Name:") You create a prompt that will display to the user. Name: In your case you have input("john") : So, the output is: John So, when you print ("Welcome" + x) You get JohnWelcome To avoid the confusion, you could do this print('Enter your name:') # Prints Enter your name: x = input() # Takes user input print("Welcome " + x) # Prints Welcome + userinput
20th Dec 2022, 4:31 AM
Chris Coder
Chris Coder - avatar
+ 6
x = input () print ("welcome" + x )
21st Dec 2022, 9:07 AM
Zahra
Zahra - avatar
+ 2
Use: print("Welcome " + x)
20th Dec 2022, 2:49 AM
NinjaGamer
NinjaGamer - avatar