I am a beginner of python and I came across such a problem. When I tried to create my own class, which is a subclass, I came across such error:
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
class gender(Enum):
File "C:\Program Files (x86)\Python365_64bit\lib\enum.py", line 208, in __new__
enum_member.__init__(*args)
TypeError: __init__() takes 1 positional argument but 2 were given
The class I made is:
class gender(Enum):
Male = 0
Female = 1
def __init__(self):
if self.value == 0:
self.sex = 'Boy'
else:
self.sex = 'Girl'
def getsex(self):
print('This person is ',self.sex)
Just want to know why __init__ is not working ....