+ 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
5 Respuestas
+ 9
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
+ 4
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
0
So it's asking for as an integer for 'level'. I tried declaring it on the string level. It kept showing as error. I have no idea and it's been like that for about a week. class Player: def __init__(self, name, level): self.name = name self.level = level def intro(self): print(f'{self.name} {self.level}') name = input() level = input() p = Player(name,level) p.intro()
4th Dec 2024, 2:50 AM
David
David - avatar
0
Sorry I tried reading an blog about resolving bugs I still don't know. In a nutshell, just says talk to a rubber ducky. I always think of simple alternatives. So to speak.
12th Feb 2025, 12:00 PM
David
David - avatar
0
Oh and I posted it on stack exchange. I'm going to have to take it down from there since I have no way resolving it. Thanks for the help.
12th Feb 2025, 12:04 PM
David
David - avatar