When to Use an Enumeration python code example
Example 1: how to use enumerate in python
rhymes=['check','make','rake']
for rhyme in enumerate(rhymes):
print(rhyme)
#prints out :
(0, 'check')
(1, 'make')
(2, 'rake')
#basically just prints out list elements with their index
Example 2: enumeration python
from enum import Enum
class Color(Enum):
RED = 1
GREEN = 2
BLUE = 3
print(Color.RED)
class Shake(Enum):
VANILLA = 7
CHOCOLATE = 4
COOKIES = 9
MINT = 3