I have the following code
num1 = 10 someBoolValue = True
I need to set the value of num1 to 20 if someBoolV
num1
20
someBoolV
For the future time traveler from google, here is a new way (available from python 3.8 onward):
b = 1 if a := b: # this section is only reached if b is not 0 or false. # Also, a is set to b print(a, b)