Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

9 filenameinput( Enter the fiLename \') 10 # open file in read mode 11 rawdopen(

ID: 3701509 • Letter: 9

Question

9 filenameinput( Enter the fiLename ') 10 # open file in read mode 11 rawdopen(filename, 'r') 12# read the content of file into content 13 contentrawd. read () 14# create an empty dictionary 15 dict - 16 # read file line by line 17 18 for line in content.split('In'): 19 20 country, incomeline.split() 21 # split using word as delimeter # store the key, value pair in dict dict [country]float (income) input (' Enter the country name : ') 23 country 24# keys() return the list of keys 25# if the entered country name is not present in dict 26 if country not in dict.keys (): 27 28 else: 29 print( 'No such country data available. ') print('Income', dict[ [country])

Explanation / Answer

Answer:

At line 20, please replace that line with below lines. it will work for sure.

words = line.split(' ')

dict[words[0]] = float(words[1])