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?
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
+ 6
x = input ()
print ("welcome" + x )
+ 2
Use:
print("Welcome " + x)