fork download
  1. a = 1
  2. b = 1
  3.  
  4. print("With elif:")
  5. if a == 1:
  6. print("a")
  7. elif b == 1:
  8. print("b")
  9. else:
  10. print("c")
  11.  
  12. print("Without elif:")
  13. if a == 1:
  14. print("a")
  15. if b == 1:
  16. print("b")
  17. else:
  18. print("c")
  19.  
  20. print("With nested else:")
  21. if a == 1:
  22. print("a")
  23. else:
  24. if b == 1:
  25. print("b")
  26. else:
  27. print("c")
Success #stdin #stdout 0.02s 9984KB
stdin
Standard input is empty
stdout
With elif:
a
Without elif:
a
b
With nested else:
a