logo-MindMajix
PostPythonPython
S
Surya kumar

Posted on 20th July 2024|25 views

0
votes

Valueerror Too Many Values To Unpack

Explain about valueerror: too many values to unpack list in python?

2 answers
Answers
P
Altaf syed

Posted on 20th July 2024| views

Sometimes, you may require to unpack the elements either values of a list. You can designate the selected values within variables or different new list. However, if the amount of list elements is higher than the amount of variables, an error called Too Many Values to Unpack. will be raised through the assignment.

 

P
malcomvx

Posted on 20th July 2024| views

Python functions can return multiple variables . These variables can be stored in variables directly. This is a unique property of Python , other programming languages such as C++ or Java do not support this by default.

The valueerror: too many values to unpack occurs during a multiple-assignment where you either don't have enough objects to assign to the variables or you have more objects to assign than variables. If for example myfunction() returned an iterable with three items instead of the expected two then you would have more objects than variables necessary to assign to.

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos
Name
Course *
Email *
Phone Number