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
Post a Comment