Hello,
pls can anybody show how works printing? here is the code:
class Student(object):
def __init__(self, name):
self.name = name
self.report = dict()
def add_subject(self, subject):
self.report[subject] = list()
def subjects(self):
return self.report.keys()
def s_subjects(self):
lpre=[]
for subject in self.subjects():
lpre.append(str(subject))
print lpre
class Subject(object):
def __init__(self, name, teacher = "unknown"):
self.name = name
self.teacher = teacher
def main():
janko = Student('Janko Moor')
janka = Student ('Janka Vaskova')
fyz = Subject('fyzic')
eng = Subject('english')
mat = Subject('matematic')
hist= Subject('history')
bio = Subject('biology')
janko.add_subject(fyz)
janko.add_subject(eng)
janko.add_subject(mat)
print janko.s_subjects()
if __name__ == '__main__':
main()
I just need to know the principe how to print the subjects of the student (janko). I am a bit struggling because it always shows me "objects" of all subjects. I need to see it like: matematic, fyzic,...etc. I really donĀ“t know what I need to add to the code to make it appropriate. Pls can you show me?