ValueError too many values to unpack expected 3

0 votes
can somebody help me
there are three numbers coming out a function
e.g.
def func(x):
.....
return a,b,c

Now its doing fine for indivual entries.

I tried this
A,B,C=func(x)

But always getting error
ValueError: too many values to unpack (expected 3)

Stuck in this from really long time.. will appreciate if somebody can help
ValueError: too many values to unpack (expected 3)

ValueError: too many values to unpack (expected 3)

ValueError: too many values to unpack (expected 3)
Aug 12, 2020 in Python by Alisha
• 140 points
2,738 views

1 answer to this question.

0 votes

Hello @Alisha ,

Do print(func(x)) and find out what's coming out, because it looks like you did it correctly.

Or else try:

A,B,C = func(x),func(x),func(x)

Hope it helps!!
Thank you!!

answered Aug 12, 2020 by Niroj
• 82,720 points
Well I changed it to now
return pd.Series(data=[a, b,c], index=['A', 'B', 'C'])

And then calling a=func(x)
a['A']
It has worked for now

Many thanks to you!!

Related Questions In Python

0 votes
0 answers

ValueError: not enough values to unpack (expected 2, got 0)

I want to load the NSL_KDD data ...READ MORE

May 9, 2020 in Python by arezoo
• 220 points

edited May 13, 2020 by Gitika 7,593 views
+3 votes
2 answers

how to print array integer without [] bracket in python like result = 1,2,3,4,5

Hey @abhijmr.143, you can print array integers ...READ MORE

answered Aug 4, 2018 in Python by Omkar
• 69,130 points

edited Aug 8, 2018 by Omkar 5,755 views
0 votes
1 answer

How to use string.replace() in python 3.x

replace() is a method of <class 'str'> ...READ MORE

answered Aug 3, 2018 in Python by Priyaj
• 58,120 points
393 views
0 votes
1 answer

How to replace values with None in Pandas data frame in Python?

Actually in later versions of pandas this ...READ MORE

answered Aug 30, 2018 in Python by Priyaj
• 58,120 points
8,082 views
0 votes
1 answer
0 votes
1 answer

How to Parse values from a JSON file?

import json from pprint import pprint with open('data.json') as ...READ MORE

answered Oct 15, 2018 in Python by Priyaj
• 58,120 points
972 views
+1 vote
10 answers

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

Just for the record: >>> int('55063.000000') Traceback (most recent ...READ MORE

answered Aug 17, 2020 in Python by pakainfo
• 200 points
264,574 views
0 votes
1 answer

How to change python version into 3.7.2 for entire pycharm jetbrains IDE projects?

Navigate to the Project page, select the configured interpreters ...READ MORE

answered Feb 27, 2019 in Python by Priyaj
• 58,120 points
951 views
0 votes
1 answer

How to keep keys/values in same order as declared?

You can't really do what you want ...READ MORE

answered Apr 13, 2020 in Python by Niroj
• 82,720 points
108 views
0 votes
1 answer

How to keep keys/values in same order as declared?

Hello @kartik, Dictionaries will use an order that ...READ MORE

answered Apr 30, 2020 in Python by Niroj
• 82,720 points
463 views