I need a function (def check) to make an instance of a class and take a list from that class.
but there are many classes and the 'key' argument passed is the number of the class I want to make an instance of.
# if the 'key' passed is 1 then it should make an instance of Class1
# if the 'key' passed is 2 then it should make an instance of Class2
def check(self, key):
list1 = Class1().list1. # it should call Class1().list1 if the key is 1 and Class2.()list1 if the key is 2
list2 = Class1().list2
list3 = Class1().list3
so how can I make the check() function change the class it makes an instance of?
I don't think I could make a if statement and change the class it calls depending on the key because there are many classes and it would be very repetitive to make 'if' statements for each class.
here are the classes:
class Class1:
def __init__(self):
self.quiz_name = 'Cities and Countries - part 1'
self.list1 = []
self.list2 = [] # the three lists
self.list3 = []
self.list1.append('Select the European City: ')
self.list2.extend(['Abu Dhabi', 'Washington DC', 'New York', 'Rome'])
self.list3.append(4)
...
class Class2:
def __init__(self):
self.quiz_name = 'Cities and Countries - part 1' # the data in the lists here are different by each class, but I'm just giving an example of the classes
self.list1 = []
self.list2 = []
self.list3 = []
self.list1.append('Select the European City: ')
self.list2.extend(['Abu Dhabi', 'Washington DC', 'New York', 'Rome'])
self.list3.append(4)
...
# there are more classes