Mar-20-2020, 03:27 PM
To implement an infinite loop, you'll need a while loop instead of a for loop. One of the purposes of a for loop is to preclude infinite looping.
Now, there are other issues with your code. Lines 4 through 6:
Now, I'm guessing you intended to check if those values are within the range(). If that's the case, you should do this:
Now, there are other issues with your code. Lines 4 through 6:
currentAge = int(input('\nEnter your current age in years: ')) for currentAge in range(1,95):currentAge is instantiated on line 4 and then reset on line 6. In a for loop, the variable following "for" is set to the current value picked out of range() (or other iterable). So, once line 6 runs, currentAge becomes 1, then 2, etc. as the loop executes. This pattern repeats in your code and is likely contributing to the problem.
Now, I'm guessing you intended to check if those values are within the range(). If that's the case, you should do this:
currentAge = int(input('\nEnter your current age in years: ')) if currentAge in range(1,95):