Question: I am getting error in line 20, ValueError: too many values to unpack (expected 2). How to fix it? 9 filenameinput( Enter the fiLename ')

 I am getting error in line 20, "ValueError: too many values I am getting error in line 20, "ValueError: too many values to unpack (expected 2)". How to fix it?

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])

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!