Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started