mercredi 6 avril 2016

If/else in python [duplicate]

This question already has an answer here:

I know this might sound silly, but I want to know if there is a way like this to use.

My code is:

print(a (+=) if a==1 else (-=) b)

What I want it to do is,

if a==1:
    print(a+b) 
else:
    print(a-b)

Aucun commentaire:

Enregistrer un commentaire