I'm confused how to access class variables while in methods. For example, what are the ways that the compare method below can use the class variable COURSES? I got it to work by adding self before calling COURSES (self.COURSES.items()), but is that correct? I feel like it is bad practice and I'm missing something, but I can't seem to find the answer. Thanks, everyone.
class Example:
COURSES = {
"Python Basics": {"Python", "functions", "variables",
"booleans", "integers", "floats",
"arrays", "strings", "exceptions",
"conditions", "input", "loops"},
"Java Basics": {"Java", "strings", "variables",
"input", "exceptions", "integers",
}
def compare(self, arg):
intersection_list = []
for key, value in COURSES.items():
if value & arg:
intersection_list.append(key)
return intersection_list