Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python syntax for an unless statement

Tags:

python

My request is simple but I do not know how to proceed:

I would like to translate an unless statement in python as followed:

taken_asks -= 1 unless taken_asks == 0

This is just one line of code which is part of a very big function. Any idea?

Thank you in advance !

like image 563
Viktor.w Avatar asked Sep 21 '26 21:09

Viktor.w


1 Answers

taken_asks -= (1 if taken_asks != 0 else 0)

like image 106
Louis Saglio Avatar answered Sep 24 '26 10:09

Louis Saglio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!