0

Python Classes

Why does this return None at the end? class Beginner_Pokemon(): Level = 5 Gender = 'Rather not say' def __init__(self,name,move_1,move_2): self.name = name self.move_1 = move_1 self.move_2 = move_2 def Moves(self): return print(f'Move 1: {self.move_1} \nMove 2: {self.move_2}') @classmethod def Pick_Gender(cls,New_Gender): cls.Gender = New_Gender Piplup = Beginner_Pokemon('Piplup','Pound','Leer',) Piplup.Pick_Gender('Female') print(Piplup.Moves())

29th Jun 2020, 7:23 PM
Prog
Prog - avatar
3 Respostas
+ 5
class Beginner_Pokemon(): Level = 5 Gender = 'Rather not say' def __init__(self,name,move_1,move_2): self.name = name self.move_1 = move_1 self.move_2 = move_2 def Moves(self): return f'Move 1: {self.move_1} \nMove 2: {self.move_2}' @classmethod def Pick_Gender(cls,New_Gender): cls.Gender = New_Gender Piplup = Beginner_Pokemon('Piplup','Pound','Leer',) Piplup.Pick_Gender('Female') print(Piplup.Moves())
29th Jun 2020, 7:25 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
+ 3
Oh ye forgot, accidently left print in it, so it printed and reurned nothing, thanks
29th Jun 2020, 7:27 PM
Prog
Prog - avatar
0
Try above you are not returning anything from the Moves.
29th Jun 2020, 7:26 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar