2.2 Write a program that uses input to prompt a user for their name and then welcomes them. Note that input will pop up a dialog box. Enter Sarah in the pop-up box when you are prompted so your output will match the desired output.
Desired output: Hello Sarah
Original sample code:
# The code below almost works
name = input("Enter your name")
Code I wrote:
I got the desired output which is: Hello Sarah Error message was that I actually had to prompt for the user's name. How do I do this?
Other advice I got:
The name Sarah cannot appear anywhere in your program. That is called hard coding a value. You only enter Sarah after you click the <Check code> button and the dialog box opens prompting you to enter a name.
There are two steps in this assignment:
- prompt the user to enter a name using the input() function
- print the string that matches the greeting in the Desired output and the variable from step 1 (which stores the user input).
The syntax for printing two objects in Python is:
How to do all this? I need help!