# this file available at: https://arachnoid.com/files/python01/ from enum import Enum from typing import Dict class Weekdays(Enum): SUN = 'Sunday' MON = 'Monday' TUE = 'Tuesday' WED = 'Wednesday' THU = 'Thursday' FRI = 'Friday' SAT = 'Saturday' ERR = 'NotADay' def activities_a(day: Weekdays) -> None: print(f'{day.value:12s} : ',end='') match day: case Weekdays.MON: print('New work week.') case Weekdays.TUE: print('Meet boss for lunch.') case Weekdays.WED: print('Golf in the PM.') case Weekdays.THU: print('Board meeting.') case Weekdays.FRI: print('TGIF!') case Weekdays.SAT: print('Go fishing.') case Weekdays.SUN: print('Sleep in.') case _: print(f'Error: value {day.value} is undefined.') def activities_b(day:Weekdays) -> None: actions : Dict[Weekdays,str] = { Weekdays.MON: 'New work week.', Weekdays.TUE: 'Meet boss for lunch.', Weekdays.WED: 'Golf in the PM.', Weekdays.THU: 'Board meeting.', Weekdays.FRI: 'TGIF!', Weekdays.SAT: 'Go fishing.', Weekdays.SUN: 'Sleep in.', } try: print(f'{day.value:12s} : {actions[day]}') except KeyError: print(f'{day.value:12s} : Key error: key {day.value} is undefined.') def main(): for day in Weekdays: activities_b(day) if __name__ == "__main__": main()