python - Using conditional expressions and incrementing/decrementing a variable -


how put if statement conditional expression , how increment/ decrement variable?

num_users = 8 update_direction = 3  num_users =  if update_direction ==3:    num_users= num_users + 1 else:    num_users= num_users - 1  print('new value is:', num_users) 

the correct statement be:

num_users = num_users + 1 if update_direction == 3 else num_users - 1 

for reference, see conditional expressions.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -