I am trying to add attributes to this class through a dictionary. I have a dictionary (dict) which follows this order
{'Subject' + str(number) : subject introduced previously}
for instance,
{'Subject0' : 'Chemistry'}
So i'm trying to implement this on a class as it follows:
class Subjects:
def __init__(self, name, dictVar, yearCourse):
self.name = name
self.dictVar = dictVar
self.yearCourse = yearCourse
self.label = self.name [0:3] + self.yearCourse
def getLabel(self):
print (self.label)
for key, value in dict.items:
key = Subjects(value, key, yearCourse)
The original code has the corresponding identation, it is a formating mistake
I took the dict.items from this question
If I run
Subject0.getLabel()
Nothing happens, since I apparently have an error in the for loop
for key, value in dict.items:
TypeError: 'builtin_function_or_method' object is not iterable
Thank you good human being if you have read this whole bible :)