lundi 18 janvier 2021

Inline Initialization of Variable

I have to set the value of exp_valu if the value of val1 is 1. I tried to this using the below code, but somehow it is failing. Where am I making mistake?

val1=1
val2=0

exp_valu = if val1: 1 else: 2
print(exp_valu)

Aucun commentaire:

Enregistrer un commentaire