TypeError: | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

TypeError:

https://code.sololearn.com/ctDhqRpE48HG/#py i put in from numstring import NumString five = NumString(5) i get this Traceback (most recent call last): File "<pyshell#14>", line 1, in <module> five = NumString(5) TypeError: __init__() takes 1 positional argument but 2 were given

20th Jan 2019, 7:13 PM
Shmuel israel Zilberman
Shmuel israel Zilberman - avatar
4 Answers
+ 3
There are two methods called __init__ in your class. The second one overrides the first one. Since it doesn't take any arguments (other than self), you can't call NumString(5). You probably meant to call the second method __int__ instead of __init__.
20th Jan 2019, 9:50 PM
Anna
Anna - avatar
0
And that's bcz you've two constructor methods in the NumString class. Omit the second one and you're good to go.
20th Jan 2019, 8:19 PM
Шащи Ранжан
Шащи Ранжан - avatar
0
What does that mean?
20th Jan 2019, 8:29 PM
Shmuel israel Zilberman
Shmuel israel Zilberman - avatar
0
Thanks you Anna
20th Jan 2019, 10:01 PM
Shmuel israel Zilberman
Shmuel israel Zilberman - avatar