Text Fileread Open Worldseriestxt R Open Reading Dctyear Dctnumwins Line Fileread Read Lin Q37019347

Word File Edit View Insert Format Tools Table Window Help Comm Share ome Insert Draw DesignLayout References Mailings Review

IDLE File Edit Shell Debug Options Window Help Python 3.7.2 Shell Python 3.7.2 (v3.7.2:9a3ffc8492, Dec 24 2018, 02:44:43) Cla

here are the text

file_read=open(‘WorldSeries.txt’,’r’) #open for reading
dctYear = {}
dctNumWins = {}

for line in file_read: #read a line from the file
team = line
data = team.split() #split the line read at spaces
dctYear[data[0]] = ”.join(data[1:]) #seperate the year and jointhe team name

file_read.close()

for key in dctYear: #create dictionary with number of wins
if dctYear[key] in dctNumWins:
dctNumWins[dctYear[key]] += 1
else:
dctNumWins[dctYear[key]] = 1

year = input(‘Enter a

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.