Jan-27-2019, 03:23 PM
Hi, I'm trying to code a basic while True loop, but I get an infinite loop whether or not I use the continue statement (after I purposely enter invalid data to test the loop):
#!/usr/bin/env python3
print("Welcome to the Miles Per Gallon Program.")
print()
milesDriven = float(input("Enter miles driven: "))
gallonsUsed = float(input("Enter the number of gallons used: "))
while True:
if milesDriven > 0 and gallonsUsed > 0:
mpg = round((milesDriven / gallonsUsed),2)
print("Miles Per Soul... uh... Gallon: ",mpg)
break
else:
print("Both entries must be greater than 0. Please Try again.")
continueWhat's wrong?
