I can not figure out why this sentinel will not work. I have searched all over for an answer to no avail. Thank you for your help!
gas = 0
miles = 0
miles = int(input("Enter number of miles driven(enter -11 to exit): "))
while miles != -11:
gas = int(input("Enter the number of gallons of gas used: "))
print ("The number of miles entered was:", miles)
print ("The number of gallons of gas used was:", gas)
mpg = miles/gas
print ("The MPG was:", mpg)
This is the result:
Enter number of miles driven(enter -11 to exit): 100
Enter the number of gallons of gas used: 10
The number of miles entered was: 100
The number of gallons of gas used was: 10
The MPG was: 10.0
Enter the number of gallons of gas used: -11
The number of miles entered was: 100
The number of gallons of gas used was: -11
The MPG was: -9.090909090909092
Enter the number of gallons of gas used:
miles
in the loop body.