0
Input and Output
I need help with the task after input and output involving names I got the first part name = input(âTomâ) I just need to solve for Alice and Bob can I please get help
3 Answers
+ 2
Please share your attempt
+ 1
# Ask the user for input and store it in a variable
name = input("Tom")
# Display the user input on the screen
+ 1
In Python we use print function to "print something on screen".
With the code below:
my_name = input("Tom") # Get user's input and store into variable named my_name.
# EDIT: However, above statement won't assign "Tom" into my_name. Instead it will print "Tom" on the screen.
# continue: The proper way is my_name = input("Please enter your name: "). The screen will display "Please enter your name: " on the screen and wait for user's input.
print(my_name) # Print the variable my_name on screen
What you get on screen:
Tom
If you are doing course exercises and have multiple cases, say case1 expecting Tom, case2 expecting Alice, you need to following code.
my_name = input()
print(my_name)
The reason you don't need to provide "Tom" and "Alice" is because the exercise case provides the name for your input function.