Site icon Machine Learning Projects

Python Program to Represent enum – 2023

Machine Learning Projects

Hey guys, in this blog we will see a Python Program to Represent enum.

Code

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)

Output

Day.FEBRUARY
FEBRUARY
2

Check out our other python programming examples

Exit mobile version