in Python, how do I get each question to repeat itself if the user enters a numb
ID: 3886509 • Letter: I
Question
in Python, how do I get each question to repeat itself if the user enters a number greater or equal to 100? i want that to be unacceptable and the original question asked again for each individual case.
while True:
bp=int(input('How many bench press reps did you perform?: '))
if bp >= 100:
print('Please enter a number less than 100. You are overtraining!')
bp=int(input('How many bench press reps did you perform?: '))
else:
break
bs=int(input('How many back squat reps did you perform?: '))
if bs>= 100:
print('Please enter a number less than 100. You are overtraining!')
bs=int(input('How many back squat reps did you perform?: '))
else:
break
mp=int(input('How many military press reps did you perform?: '))
if mp>=100:
print('Please enter a number less than 100. You are overtraining!')
mp=int(input('How many military press reps did you perform?: '))
else:
break
dl=int(input('How many deadlifts did you perform?: '))
if dl>=100:
print('Please enter a number less than 100. You are overtraining!')
dl=int(input('How many deadlifts did you perform?: '))
else:
break
Explanation / Answer
// this program asks repeatedly all the sources . After done the program starts once again due to
//line1 while loop since it is true
//That You want t run it for one time remove while loop line1
while True:
bp=int(input('How many bench press reps did you perform?: '))
while bp >= 100:
print('Please enter a number less than 100. You are overtraining!')
bp=int(input('How many bench press reps did you perform?: '))
bs=int(input('How many back squat reps did you perform?: '))
while bs>= 100:
print('Please enter a number less than 100. You are overtraining!')
bs=int(input('How many back squat reps did you perform?: '))
mp=int(input('How many military press reps did you perform?: '))
while mp>=100:
print('Please enter a number less than 100. You are overtraining!')
mp=int(input('How many military press reps did you perform?: '))
dl=int(input('How many deadlifts did you perform?: '))
while dl>=100:
print('Please enter a number less than 100. You are overtraining!')
dl=int(input('How many deadlifts did you perform?: '))
print("Done")
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.