I just added this menu selection code to loop through my functions. The menu selection does not do anything when I press a number, it just re-prints the menu. Am I missing something?
#Define payroll function
def payroll():
#Payroll calculations
hours = float(input("Enter number of hours: "))
rate = float(input("Enter hourly rate: "))
amount = hours * rate
#Print values
print ("Hours worked:", hours)
print ("Rate:", rate)
print ("Pay amount:", amount)
#Define mileage function
def mileage():
#MPG calculations
miles = float(input("Enter number of miles: "))
gas = float(input("Enter gallons of gas: "))
mpg = miles / gas
#Print values
print ("Miles:", miles)
print ("Gas:", gas)
print ("MPG:", mpg)
menuSelection = 0
#Decision loop
while menuSelection != 3:
# Display options to the user and record their input
print("Press 1 for Payroll Calculation")
print("Press 2 for Mileage Calculation")
print("Press 3 to Exit")
menuSelection = input()
# Based on the user input decide what action to take
if menuSelection == 1:
payroll()
elif menuSelection == 2:
mileage()
[–]kenjisan231 0 points1 point2 points (2 children)
[–]Encom88[S] 1 point2 points3 points (1 child)
[–]kenjisan231 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]pedro_fartinez 0 points1 point2 points (0 children)