Question: PYTHON 3.8 class student(): def __init__(self, name = 'Bill', grade = 9, subjects = ['math','science']): self.name = name self.grade = grade self.subjects = subjects def

PYTHON 3.8

class student():

def __init__(self, name = 'Bill', grade = 9, subjects = ['math','science']): self.name = name self.grade = grade self.subjects = subjects

def add_subjects(self): print('Current subjects:') print(self.subjects) more_subjects = True while more_subjects == True: subject_input = input('Enter a subject to add: ') if subject_input == '': more_subjects = False print(self.subjects) else: self.subjects.append(subject_input) print(self.subjects)

m = student() d = student()

why is it that when i execute function add_subjects that it adds the subject to both class objects

for example m.add_subjects() will add the subject to m and d

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!