I have the following code so far. I want to display unit1 information as a string but the prereq details are stored in a list and I am not quite sure why it is blank instead of displaying math, Python
class The_Unit:
def __init__(self,code,name,prereq=[]):
self.code = code
self.name = name
self.prereq =[]
def __repr__(self):
return self.__str__()
def __str__(self):
return 'Code: ' + self.code + \
'\nName: ' + self.name + \
'\nprerequisites: ' + '\n'.join((str(x) for x in self.prereq))
unit1 = The_Unit('11','coding',['math','python'])
print(unit1)
Code: 11
Name: coding
prerequisites: