Objective
Create a Python program that looks up a member of an enumeration by its name and goes through the enumeration.
Instructions
- Define
class Color(Enum)withRED = 1,GREEN = 2andBLUE = 3. - Read the name of a color and look it up with
Color[name]. If it does not exist, Python raisesKeyError: showUnknown color. - If it exists, show
Value: Vand, on the next line,Next: NAME, with the member that follows in the enumeration (afterBLUEit goes back toRED). Uselist(Color)to get the members in order.
GREEN
Value: 2
Next: BLUE
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise