dimanche 13 décembre 2020

Why is my if statement not working even when true? If statement is inside function, but works outside a function

def PER_Calc(PERatio,PECom):
    print("I am here")
    print(PERatio,"inside")
    if PERatio >= 0 and PERatio <= 18:
        PECom = 10
        PERatio = PERatio + 2
    return PECom

PECom = 0
PERatio = 18
PER_Calc(PERatio,PECom)
print(PERatio)
print(PECom)

RESULTS ARE

I am here
18 inside
18
0

SHOULD BE

I am here
18 inside
20
10

Aucun commentaire:

Enregistrer un commentaire