0

I have a question about the lesson "Taking User Input" in the last challenge - PYTHON

Well, the last question given is this: "Imagine you're working on a new contact management system. The program needs to ask the user to enter their name and age. You need to produce the following output: "name is age years old", where name and age are variables. There's something wrong with the given code. Can you fix it? Complete the code so that the name and age can be supplied by the user. Example entry: Ana 18 Example output: Anna is 18 years old" so far, so good, but it asks to add "Dan" "21" in Test Case 2, but I have no idea which code to use, because : name = input = ("Anna") age = input = (18) print("Anna" + " is " + "18" + " years old") name = input = ("dan") age = input = (21) print("dan" + " is " + "21" + " years old") does not work :/ (Introduction to Python) sorry for any mistakes in english, i'm still learning

18th Oct 2023, 6:45 PM
ishi
ishi - avatar
1 Answer
+ 6
ishi , Go through the lessons properly...as you made syntax error in your code.... Age is a integer value so it should be taken as int(input()) And you should not Hard code the values in print statement... You should mention the variable names there.... Here take a look at this, name = input() age = int(input()) print(name , " is " , age , " years old") This will work
18th Oct 2023, 7:09 PM
Riya
Riya - avatar