I'm having trouble with OOP in Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I'm having trouble with OOP in Python

This is my first run at OOP in Python. Every time I run the code to get the stats of an employee, it shows None beneath it. I'm sure it might be something I missed in creating the method for it, but I'm not sure how to fix it. https://code.sololearn.com/csH6MH756YW3/?ref=app

1st Jul 2023, 3:27 PM
Riaan
Riaan - avatar
3 Answers
+ 5
In this function (stat) you are not returning value so here None will be print print(i.stat()) so just call function
1st Jul 2023, 3:44 PM
A͢J
A͢J - avatar
+ 2
yes, just use i.stat() not print(i.stat()) this will call the function (which prints the stat), but will also print the return value of i.stat() which is None.
1st Jul 2023, 4:02 PM
Bob_Li
Bob_Li - avatar
0
Got it. Thank you!
1st Jul 2023, 4:41 PM
Riaan
Riaan - avatar