将 python 代码转换为模块化 python

convert python code into modular python

我无法将我的 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()

是这样的吗?

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