Conditional loops will keep repeating until a condition is met.
The condition can be checked at the start of the the loop:
1 2 3 4 5 6 7 | # age = 0 #anything except -1 while age ! = - 1 : age = int ( input ( 'Enter age, -1 to finish:' )) days = round (age * 365.25 ) print (f 'You are over {days} days old' ) # |
or at the end (this is effectively a repeat-until loop):
1 2 3 4 5 6 7 8 | # while True : age = int ( input ( 'Enter age, -1 to finish:' )) days = round (age * 365.25 ) print (f 'You are over {days} days old' ) if age = = - 1 : break # |