+ 2
So this what I'm trying to solve
So I'm having a lot of troubles it saying to write print() after I think name = input(). it won't tell where and I have no whether the def__init__ underscore space is ok... class Player: def __init__(self, name, level): self.name = name self.level = level def intro(self): print(self.name + "(Level " + self.level + ")" #your code goes here name = input() level = input() p = Player(name, level) p.intro()
2 Réponses
+ 5
https://sololearn.com/compiler-playground/c47yhaKP7083/?ref=app
David ,
your entire code is almost correct there is just a syntax problem in closing bracket at "intro" function
Rest all it shows output as per the code
input goes:
john
12
+ 2
David ,
instead of using concatenation (which may looks a bit confusing), we can use an f-string to do the task:
...
print(f'{self.name} (Level {self.level})')
...