• 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

Please log in or register to answer this question.

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 82 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 137 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 2 views
Problem: I know there is a ton of these threads but all of them are for very simple cases like 3x3 matrices and things of that sort and the solutions do not even begin to apply to my situation. So I'm trying to graph G versus l1 (that's not an eleven, but an ... 250 data points. I had another user (shout out to Hugh Bothwell!) help me with an error in my code, but now another error has surfaced.
asked Jan 6 Mashhoodch 5.7k points
1 vote
1 answer 3.1K 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, 2020 stewart 4k points
1 vote
2 answers 282 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, 2020 Gavin 15.3k points
0 votes
1 answer 72 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, 2020 Daniel Anderson 4k points
0 votes
1 answer 185 views
Problem : I am getting following error in my error log file [18-Nov-2019 19:09:55 UTC] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1040] Too many connections' in /home/root/products/db.php:2 Stack trace: /home/ ... ', 'root', '**somePassword**'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
asked Nov 20, 2019 peterlaw 6.9k points
1 vote
2 answers 1.8K views
Problem: I wrote a code in python but it throws me a error message: Please enter your number: 13 Traceback (most recent call last): File "tst.py", line 20, in <module> (lub, sup) = fib_intervall(a) TypeError: cannot unpack non-iterable NoneType object The code I ... me but after that the code is not running and throwing me this error message. Is there any problem in my code and how to solve this?
asked Apr 24, 2020 samhaz 5k points
0 votes
2 answers 1.7K views
Problem : While I am running the python code on windows with python 3.5 64 bit. Getting below error. overflowerror: python int too large to convert to c long
asked Oct 22, 2019 peterlaw 6.9k points
0 votes
1 answer 4 views
How can I solve this problem?
asked Jan 4 TeamScript 9.9k points