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
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
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
what does enumerate do in python
The enumerate() function assigns an index to each item in an
iterable object that can be used to reference the item later.
What does enumerate do in Python? It makes it easier to keep
track of the content of an iterable object.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us