You want to look at a while loop
eg:
# Set the target value
target = 50
# Initialize the running total to 0
total = 0
run the indented code while target != total
while total != target:
# ask the user for a number
choice = input("Number? ")
# add choice to total
total += choice
The above will keep running the while
block while total != 50
evaluates to True
.
2
solved Write a Python program that repeatedly asks the user to input coin values until the total amount matches a target value