将python代码转换为模块化python

时间:2016-10-16 21:02:42

标签: python modular

我无法将我的python代码转换为模块化python。任何人都可以帮助我吗?

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()

1 个答案:

答案 0 :(得分:0)

这样的东西?

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()