• Register
1 vote


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

1 Answer

0 votes


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 58 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 LizzyM 6.1k points
1 vote
1 answer 102 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 Gavin 15.3k points
1 vote
1 answer 1.9K views
Problem : I am new to Python and Pandas. The astype in my below code raises the ValueError if I use the dict of columns. Now I am trying to convert a type of sparse column in the big DF (from float to int). But the problem is with a NaN values. I ... error I am facing currently: ValueError: Cannot convert non-finite values (NA or inf) to integer . I need experts help to fix above ValueError.
asked Apr 23 stewart 4k points
1 vote
2 answers 125 views
Problem: Hello guys, Well, I am working with a NumPy array after learning the array a little bit. I am trying to print a particular element from each row from a two-dimensional array. While I am trying to run the program it returns an error Indexerror: too many indices for ... ;s wrong with this and how may I get rid of this? I am looking forward to hearing back from you guys. Thanks a lot.
asked Apr 21 Gavin 15.3k points
0 votes
1 answer 10 views
I am trying to figure out why this error showing in my case and searching several website didn't get the desired result. In this website can someone can someone show me correct way to solve this ValueError: Must pass DataFrame with boolean values only.
asked Sep 14 Daniel Anderson 4k points