+ 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()

27th Nov 2024, 2:08 AM
David
David - avatar
2 Respuestas
+ 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
27th Nov 2024, 3:21 AM
Suparna Das
Suparna Das - avatar
+ 3
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})') ...
27th Nov 2024, 10:45 AM
Lothar
Lothar - avatar