dimanche 24 mai 2020

If/elif/else loop executing else statement when if is met

I have the following code as part of a function:

print("Is the fluid water/steam or R-134a: ")
fluid = input()
if fluid.casefold == "water":
    hin = CP.PropsSI('H','P', pin,"T",lower_temp+zeroC, 'water')
    hout = CP.PropsSI('H','P', pout,"T",upper_temp+zeroC, 'water')
    return
elif fluid.casefold == "r134a" or fluid.casefold == "r-134a":
    hin = CP.PropsSI('H','P', pin,"T",lower_temp+zeroC, 'R134a')
    hout = CP.PropsSI('H','P', pout,"T",upper_temp+zeroC, 'R134a')
    return
else:
    print("Invalid Fluid")
    params()

My code always executes the else statement, not the if or elif statements. Am I using casefold incorrectly, or is there some other error that I'm not seeing

Aucun commentaire:

Enregistrer un commentaire