1# Here is one way to implement a switch construct
2# Switcher is a dictionary data type here
3def week(i):
4 switcher={
5 0:'Sunday',
6 1:'Monday',
7 2:'Tuesday',
8 3:'Wednesday',
9 4:'Thursday',
10 5:'Friday',
11 6:'Saturday'
12 }
13 return switcher.get(i,"Invalid day of week")
14
15print(week(5)) # Call the function
1def switch_demo(argument):
2 switcher = {
3 1: "January",
4 2: "February",
5 3: "March",
6 4: "April",
7 5: "May",
8 6: "June",
9 7: "July",
10 8: "August",
11 9: "September",
12 10: "October",
13 11: "November",
14 12: "December"
15 }
16 print switcher.get(argument, "Invalid month")
17