samedi 2 novembre 2019

If statement inside a function python

If statement inside per only executes the else line, none of the above works. Also, if salary is defined as salary(hour, worktype) again it does not work. Why?

hour=int(input("Enter your hours of work: "))
worktype=input("Enter your worktype: ")

def per(worktype):
    if worktype =="A":
        return(8)
    elif worktype =="B":
        return(10)
    else:
        return(15)


x=per(worktype)
def salary(hour, x):
    print("Your total salary is:", hour * x)

salary(hour, x)

Aucun commentaire:

Enregistrer un commentaire