Python Forum
too many values to unpack error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
too many values to unpack error
#2
This is your problem:

(i, j) = str('Jan')
You have two variables on the left side, and an iterable on the right ('Jan'). So python goes through the iterable and assigns 'J' to i, and 'a' to j, and then raises the error when it has nowhere to assign 'n'. If you want to assign 'Jan' to both i and j, you need:

i, j = 'Jan', 'Jan'
Note that I didn't use str('Jan'). That's because str('Jan') is redundant: 'Jan' is already a str.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
too many values to unpack error - by fyec - Jun-27-2018, 11:02 PM
RE: too many values to unpack error - by ichabod801 - Jun-28-2018, 01:48 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Too much values to unpack actualpy 3 483 Feb-11-2024, 05:38 PM
Last Post: deanhystad
  Trying to use 2 values from excel in my script but getting error.. cubangt 3 1,687 May-11-2022, 07:12 AM
Last Post: normanwolf
  unpack dict menator01 1 1,202 Apr-09-2022, 03:10 PM
Last Post: menator01
  ValueError: not enough values to unpack (expected 4, got 1) vlearner 2 6,342 Jan-28-2022, 06:36 PM
Last Post: deanhystad
  [SOLVED] [geopy] "ValueError: too many values to unpack (expected 2)" Winfried 2 2,877 Mar-30-2021, 07:01 PM
Last Post: Winfried
  Cannot unpack non-iterable NoneType object, i would like to ask for help on this. Jadiac 3 8,935 Oct-18-2020, 02:11 PM
Last Post: Jadiac
  Argparse error when inputting values tqader 2 2,892 Sep-11-2020, 07:42 PM
Last Post: buran
  subprogram issues: cannot unpack non-iterable function object error djwilson0495 13 6,018 Aug-20-2020, 05:53 PM
Last Post: deanhystad
  struct.unpack failed Roro 2 3,367 Jun-13-2020, 05:28 PM
Last Post: DreamingInsanity
  Can't unpack values of dictionary with ** Snake 3 3,579 Mar-11-2020, 11:17 AM
Last Post: Snake

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020