-2

im having trouble converting my python code into modular python. Can anyone help me out?

keep_going = "y"

while keep_going == "y":
    sales = float(input("Enter the amount of sales: "))
    comm_rate = .10

    commission = sales * comm_rate

    print ("The commission is: ", commission)

    keep_going = input("Do you want to calculate another commission? (Enter y for yes): ")

main()
Tammo Heeren
  • 1,966
  • 3
  • 15
  • 20

1 Answers1

0

Something like this?

def main():
    keep_going = "y"

    while keep_going.lower() in ['y', 'yes'],:
        sales = float(input("Enter the amount of sales: "))
        comm_rate = .10
        commission = sales * comm_rate
        print ("The commission is: ", commission)

        keep_going = input("Do you want to calculate another commission? (Enter y for yes): ")

main()
Tammo Heeren
  • 1,966
  • 3
  • 15
  • 20