I want to make the class score in python that takes each subject's score and return its average and sum. I know if I receive 4 arguments than denominator of average should be 4, but how I can make it to fixed codes that changed by number of inputs?, not just count numbers and type 4. I tried Len(self) or using for loop to count but Len makes error and for loop isn't that easy.
class score:
def __init__(self, language, math, english, science):
self.language = language
self.math = math
self.english = english
self.science = science
...
def sum_scores(self):
result = self.language + self.math + self.english + self.science
return result
def average(self):
average = self.sum_scores()/4 # Here is the problem!
return average
This is my first question on stack. so sorry for my poor English and stupid questions.