What I am trying to do here is read a line of a file. If the content in the file meets the correct criteria execute one of the definitions in my class. The thing is I have no clue on what kind of code I need for this.
here is what I have so far:
class Score:
# class to hold a running score, from object to parameter
# also to set number of scores that contribute to total of 1
def __init__(self):
#initalizes the running score and score input accumilators
self.runScore = 0
self.scoreInputs = 0
def updateOne (self, amount):
#updates running score by amount and Score input by 1
self.runScore += amount
self.scoreInputs += 1
def updateMany(self,lst):
#updates running score by the sum of the list and score inputs by the amount of
# number of items in the list
self.runScore += sum(lst)
self.scoreInputs += len(lst)
def get(self):
#returns the current score based on total amount scored
print(self.runScore)
def average(self):
#returns the average of the scores that have contributed to the total socre
print(self.runScore // self.scoreInputs)
def processScores (file):
with open('file','r') as f:
for line in f:
line
The Idea is that processScores will be ran. As the code reads the file line by line if it finds a certian marker in the line example G then the next line it reads shall be input into the def updateOne. But thats just an example.
Anyideas on what I can do better?
Thank you