0

Is there a shorthand way to do something like this (preferably all in one line)?

if something:
    var = "thing"
else:
    var = "other thing"
Ang_d
  • 39
  • 3

1 Answers1

0

This works

 a = 3 if True else 4

Sets a to 3 if first condition met (here True) else to 4

Lukas Nothhelfer
  • 820
  • 1
  • 7
  • 23