0
why not return lec students name?
class student: def __init__(self,*name): self.name=list(name) def stud(self): return self.name stu=student("david","nick") print(stu.stud()) class lector(student): def st(self): return self.name lec=lector() print(lec.st())
1 Resposta
+ 1
It's because you didn't pass any name when you created the lec object.
If you had done
lec = lector("david", "nick")
print(lec.st()) would return ["david", "nick"]
You did create the object stu, but there's nothing that associates lec with stu.