+ 3
Can someone help me inspect the error in this code, anytime I run it it returned an error. [SOLVED]
class Player: def init(self, name, level): self.name = name self.level = level def intro(self): print(self.name + " (Level " + self.level + ")") name=input() level=input() p=Player(name,level) p.intro()
12 odpowiedzi
+ 2
Thank you so much
It worked Sanjyot21
https://code.sololearn.com/cIRxVyeL5C44/?ref=app
+ 6
YIPMONG there should be double underscore before and after........
You have entered only single
+ 4
YIPMONG you forgot the double underscore before and after init.
Use def __init__ (self,name,level).
It should work fine.
+ 2
Sanjyot21 i did put that and it still returned an error
+ 2
YIPMONG can you share that code
+ 2
+ 1
YIPMONG you're welcome
+ 1
Only you need to correct init with __inint__
+ 1
Bro __init__ write like this
+ 1
Your constructor has syntax error
+ 1
class Player:
def __init__(self,name,level): #here you did a mistake
self.name=name
self.level=level
def intro(self):
print(self.name, "level", self.level). #here you did a mistake, you cant add string to integer, to print use (,) comas
name=input()
level=input()
p=Player(name,level)
p.intro()
0
Can anyone please explain to me why we use __inint__