3 Réponses
+ 6
https://docs.python.org/3/library/enum.html
from enum import Enum
class States(Enum):
WA = "Washington"
OR = "Oregon"
CA = "California"
UT = "Utah"
NY = "New York"
print(States.WA.value)
+ 4
It's a built-in function, no library needed.
https://docs.python.org/2/library/functions.html#enumerate
+ 3
I guess it depends on which one you're asking about. Enumerate and enumerations are not the same thing, but you have an answer for either, so.... you should be good either way!