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
5,799 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,840 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 11,901 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 5, 2018 in Python by Omkar
• 69,220 points

edited Aug 8, 2018 by Omkar 8,131 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,020 points
1,122 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,020 points
11,704 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,020 points
1,988 views
+2 votes
10 answers

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

The following are totally acceptable in python: passing ...READ MORE

answered Nov 16, 2018 in Python by Nymeria
• 3,560 points
409,149 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,020 points
3,347 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,840 points
678 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,840 points
1,877 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP