Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- succeed = False
- fileName = None
- fileContent = None
- while not succeed:
- try:
- fileName = input("Enter a file name: ")
- fileContent = open(fileName, "r")
- succeed = True
- except OSError:
- print("Could not open", fileName)
- succeed = False
- totalGrades = 0
- totalScore = 0
- for ln in fileContent:
- splittedStr = ln.split()
- totalScore = totalScore + int(splittedStr[2])
- totalGrades = totalGrades + 1
- print("The average score is:", str(round(totalScore / totalGrades, 1)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement