mardi 12 novembre 2019

Setting user input answer as a variable for future if...else statement

So basicaly i want the answer of the user input no become a variable so i can use that variable later on. I have tried multiple ways of doing it but every time the user input doesn't seem to become a variable.

It doesn't seem to recognize the variables sexe and smoker, but age works fine.

Any ideas?

Thanks!

input_age = input("Votre age ")
age = int(input_age)

cat1=age<50
cat2=50<=age<55
cat3=55<=age<60
cat4=60<=age<65
cat5=age>=65

input_sexe=input("male or female (m/f)? ")
ho, fe = "h", "f"
if input_sexe == "m":
 input_sexe=ma
if input_sexe == "f":
 input_sexe=fe

input_sm=input("Smoker? ")
sm, nsm = "yes", "no"
if input_sm == "yes":
 input_sm=sm
if input_sm == "no":
 input_sm=nsm


fe_cat1_sm= cat1 and fe and sm

ma_cat1_sm= cat1 and ma and sm

SCORE0 = (fe_cat1_sm)
if SCORE0:
 print("SCORE 0%")

SCORE1 = (ma_cat1_sm)
if SCORE1:
 print("SCORE 1%")
```



Aucun commentaire:

Enregistrer un commentaire