-1

I know this is possible:

a, b = 5, 10
print 'a' if a > b else 'b'  # outputs b

However, what if I had another variable 'c'? How do I make them print in the same line using the same type of logic as those two variables? Something like?

a, b, c = 5, 10, 20
print 'a' if a > b elif 'b' if b > c  else 'c'  # is it possible?

Just to mention: I know it's a bad practice, I just wanted to know.

QuestionEverything
  • 4,809
  • 7
  • 42
  • 61

1 Answers1

5

There is no elif, use else multiple times:

print 'a' if a > b else 'b' if b > c else 'c'
Daniel
  • 42,087
  • 4
  • 55
  • 81