Hey guys, in this blog we will see a Python Program to Represent enum.
from enum import Enum class Day(Enum): JANUARY = 1 FEBRUARY = 2 MARCH = 3 # print the enum member print(Day.FEBRUARY) # get the name of the enum member print(Day.FEBRUARY.name) # get the value of the enum member print(Day.FEBRUARY.value)
Day.FEBRUARY FEBRUARY 2
- Here we have used enum.ENUM to create a Day class.
- Day.FEBRUARY will give Day.FEBRUARY as the output.
- Day.FEBRUARY.name will give FEBRUARY as the output.
- Day.FEBRUARY.value will give 2 as the output.
Check out our other python programming examples…