-2

In java, I usually use

boolean x = a? b : c;

instead

if(a)
    boolean x = b;
else
    boolean x = c;

Is there any possibility for doing that in python?

1 Answers1

2

You can do:

x = b if a else c

which means the same thing.

Simeon Visser
  • 118,920
  • 18
  • 185
  • 180