I know I can do this:
z = a if switch == 1 else z = b
but what if I want z=a if switch=1, z=b if switch=2, and z=c if switch=3? Is there a python valid way to write this as a single line?
something like:
z = a if switch == 1 else z = b if switch == 2 else z = c
Thanks, just learning Python now (obviously).
z = a if switch == 1 else z = bis not valid since the assignmentz = bis a statement, not an expression. I think you meanz = a if switch == 1 else b:-)