• Register
1 vote
43 views

Problem:

I am getting the 'valueerror:too many values to unpack' error. Any idea how I can fix this?

Here is my sample program

first_names = ['foo', 'bar']
last_names = ['gravy', 'snowman']

fields = {
    'first_names': first_names,
    'last_name': last_names,
}        

for field, possible_values in fields:  # error happens on this line    

 

12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution:

Since Python 3 iteritems() is no longer supported. Use items() instead.

for field, possible_values in fields.items():
    print(field, possible_values)

 

13 9 6
94,240 points

Related questions

1 vote
1 answer 3 views
3 views
Problem: Any ideas on what I need to do to fix this? python valueerror: too many values to unpack
asked Mar 19 MUHAMMAD MUNEEB 83k points
0 votes
1 answer 26 views
26 views
Problem: I am a python beginner . I was trying to run this code : def main(): print ( " This program computes the average of two exam scores . ") score1,score2 = input ("Enter two scores separated by a comma:") average = (score1 + score2)/2.0 print ("The ... average ) when I summon the main() I got this ValueError : ValueError: too many values to unpack (expected 2) what is wrong with this code ?
asked Feb 17 Mashhoodch 13k points
1 vote
1 answer 3 views
3 views
Problem: Please help me to solve it out : python too many values to unpack
asked Mar 19 MUHAMMAD MUNEEB 83k points
0 votes
1 answer 4 views
4 views
Problem: I am getting the 'too many values to unpack' error. Any idea how I can fix this?
asked Mar 17 ummesalma 25.2k points
0 votes
1 answer 2 views
2 views
Problem: ValueError: not enough values to unpack (expected 11, got 1).I wrote a script for system automation, but I'm getting the error described in the title.What is the problem?
asked 4 days ago sumaiya simi 16k points
0 votes
1 answer 14 views
14 views
Problem: How to I Solve this: valueerror: not enough values to unpack (expected 2, got 0) HELP! I need help understanding this: valueerror: not enough values to unpack (expected 2, got 0) Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked Mar 6 Mashhoodch 13k points
0 votes
1 answer 16 views
16 views
Problem: i am getting error: ValueError: need more than 2 values to unpack when i run the unit test now, so 2 failures and one skip now as far as i have read about lambda i: get_error_count(self._error_lookup, i)) line 142 of source is the method for test, err, ... = get_error_count(i) reference Python 3.0 has something a bit like this. Excess values can be bound (as a list) to the last variable:
asked Feb 15 Mashhoodch 13k points
1 vote
1 answer 141 views
141 views
Problem: For the following code I got some error message like: ValueError: not enough values to unpack (expected 3, got 2) The code: import openpyxl, smtplib, sys wbs = openpyxl.load_workbook('duesRecords.xlsx') sheet = wb.get_sheet_by_name('Sheet1') lastCol = sheet. ... problem sending email to %s: %s' % (email, sendmailStatus)) smtpObj.quit() Can anyone help me out to solve this problem?
asked Apr 8, 2020 LizzyM 6.1k points
1 vote
1 answer 166 views
166 views
Problem: I am getting an error while I am trying to run a python program. Please have a look at it and give me a solution if possible. I am trying to figure the problem but I fail to do so. from sys import argv script, usr_name =argv prompt = '>' ... more than 1 value to unpack” Traceback (most recent call last): script, usr_name =argv ValueError: need more than 1 value to unpack Thanks.
asked Mar 28, 2020 Gavin 15.3k points
0 votes
1 answer 14 views
14 views
Problem: How to deal with c++ too many initializer values?
asked Mar 22 Ifra 24.4k points