Input and Output | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

6th Jul 2023, 3:46 AM
Turin Urbina Jaramillo
3 Answers
+ 2
Please share your attempt
6th Jul 2023, 3:49 AM
Sakshi
Sakshi - avatar
+ 1
# Ask the user for input and store it in a variable name = input("Tom") # Display the user input on the screen
6th Jul 2023, 4:08 AM
Turin Urbina Jaramillo
+ 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.
6th Jul 2023, 4:52 AM
Wong Hei Ming
Wong Hei Ming - avatar