DEV Community

Discussion on: Switch case, python?

Collapse
 
gwutama profile image
Galuh Utama

I'm not a big fan of deeply nested blocks. It's just like you mentioned. I would use if elif else in python as replacement of switch.

if plants == 1:
  print("Tulip")
elif plants == 2:
  print("Rose bush")
elif plants == 3:
  print("Pineapple")
elif plants == 4:
  print("Banana")
else:
  print("enter a valid option")