+ 1

Can you have an input string print input of a previous string?

Im trying to make a program that keep arrays of 2 things, a pets age and a pets name Is there away to have the output be "Enter (previously entered pets name) age" Here is what I am currently trying def addItem(names, ages): aName = "" aAge = 0 #read a name and score from the user aName = input("Enter pets name: ") aAge = input("Enter age for", aName) #add the name and score to the lists names.append(aName) ages.append(aAge)

20th May 2022, 3:40 AM
Kelli
1 Réponse
+ 1
Kelli You can use f-strings in input prompts . name = input("Enter pet's name:\n") age = input(f"Enter {name}'s age:\n") Unfortunately, this does not work properly in Sololearn's playground. (You see it only after you have submitted the inputs.)
20th May 2022, 3:57 AM
Bob_Li
Bob_Li - avatar