This is my program. Everything works except the part where I need to put the bowler name, score and title (average, perfect, below average, above average). How to I make sure that all parts get into the outfile? Thanks so much!
*** OK, so I got the file output correct EXCEPT none of the titles were added. I need the output to look something like this:
Jane 160 Below Average Hector 300 PERFECT! Mary 195 Above Average Sam 210 Above Average David 102 Below Average
scores = {}
def bowl_info(filename):
infile = open("bowlingscores.txt", "r")
total = 0
for line in infile:
if line.strip().isdigit():
score = int(line)
scores[name] = score
else:
name = line.strip()
return scores
def titles():
for name, score in scores.items():
if score == 300:
print name , score, "PERFECT!"
elif score < average:
print name , score, "Below Average"
elif score > average:
print name , score, "Above Average"
else:
print name , score, "Average"
bowl_info("bowlingscores.txt")
numbowlers = len(scores)
total = sum(scores.values())
average = total / numbowlers
titles()
for items in scores.items():
outfile = open("bowlingaverages.txt", "w")