2016-10-16 2 views
-2

ich habe Probleme bei der Umwandlung meiner Python-Code in modulare Python. Kann mir jemand helfen?konvertieren Python-Code in modulare 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() 
+0

Nicht klar, was Sie fragen –

+0

versuchen Sie, dies zu einem Modul zu machen? – n1c9

+0

Was ist 'main()'? Ist das die "while" -Schleife, die du geschrieben hast? –

Antwort

0

So etwas ähnliches?

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