With the help of enum.auto() method, we can get the assigned integer value automatically by just using enum.auto() method.
Syntax :
enum.auto()Automatically assign the integer value to the values of enum class attributes.
Example #1 :
In this example we can see that by using enum.auto() method, we are able to assign the numerical values automatically to the class attributes by using this method.
# import enum and autofrom enum import Enum, auto  # Using enum.auto() methodclass language(Enum):    Java = auto()    Python = auto()    HTML = auto()  print(list(language)) |
Output :
[,, ]
Example #2 :
# import enum and autofrom enum import Enum, auto  # Using enum.auto() methodclass language(Enum):    Cpp = auto()    JavaScript = auto()    Java = auto()    Python = auto()    HTML = auto()  print(list(language)) |
Output :
[,,,, ]

… [Trackback]
[…] Here you will find 13336 additional Info to that Topic: geeksforgeeks.org/enum-auto-in-python/ […]
… [Trackback]
[…] Information to that Topic: geeksforgeeks.org/enum-auto-in-python/ […]
… [Trackback]
[…] There you will find 19070 additional Info on that Topic: geeksforgeeks.org/enum-auto-in-python/ […]