For example, I have:
def run():
x = input()
switch (x):
case 1:
print "case 1"
case 2:
print "case 2"
break;
case 3:
print "3"
case (4,5):
print "4"
print "5"
break;
default:
print "default"
It is just pseudocode on Python. I tried to rewrite this program using real Python syntax:
def run():
x = input()
if x == 1:
print ("case 1")
if x == 1 or x == 2:
print ("case 2")
else:
if x == 3:
print ("3")
if x == 3 or x == 4 or x == 5:
print ("4")
print ("5")
else:
print ("default")
Looks very ugly. Can I do this in another way; for example, using dictionaries?