I've been working on this code all night and i can't seen to find out how to do the math i think it needs a loop of some kind on line 17 and 18 also it wont print out the avg mpg please help
def main():
1 print("This program calculates fuel efficiency over a multi-leg journey.")
2 print("You should enter the gallons of gas consumed and miles traveled")
3 print("for each leg. Just hit <Enter> to signal the end of the trip.")
4 print()
5
6
7 total_distance, total_fuel = 0.0, 0.0
8 inStr = input("Enter gallons and miles (with a space between): ")
9 while inStr != "":
10 gallons,miles = inStr.split()
11 gallons = eval(gallons)
12 miles = eval(miles)
13
14 #This next line should print just the miles per gallon for the leg of the trip 15 you just received from the user
16 print("MPG for this leg: {0:0.1f}".format(miles/gallons))
17 total_distance = miles + miles
18 total_fuel = gallons + gallons
19 inStr = input("Enter gallons and miles (with a space between): ")
20
21
22 print()
23 #This section should print the TOTAL distance & TOTAL fuel used during the trip
24 print("You traveled a total of {0:0.1f} miles on {1:0.1f} gallons."
25 .format(total_distance, total_fuel))
26 #This section should print the average based on the TOTAL distance & TOTAL fuel 27 27 used during the trip
28 print("The fuel efficiency was {0:0.1f} miles per gallon."
29 .format(total_distance/total_fuel))
30
31 if __name__ == '__main__':
32 main()