Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8367109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:04:45+00:00 2026-06-09T13:04:45+00:00

A simplification of my dictionary: my_dict = { ‘DOC’: [ [(‘k’, ‘v’), (‘k1’, ‘v1’),

  • 0

A simplification of my dictionary:

my_dict = {
    'DOC': [
        [('k', 'v'), ('k1', 'v1'), ('k2', 'v2'), ('k3', 'v3'), ('k4', 'v4')],
        [('k5', 'v5'), ('k', 'v'), ('k1', 'v1'), ('k6', 'v6')]
    ],
    'DIC': [
        [('k7', 'v7'), ('k3', 'v3'), ('k8', 'v8')],
        [('k5', 'v5'), ('k3', 'v3'), ('k1', 'v1'), ('k2', 'v2')],
        [('k4', 'v4'), ('k9', 'v9')]
    ],
    'INFRA': [
        [('k5', 'v5'), ('k3', 'v3'), ('k1', 'v1'), ('k2', 'v2')],
        [('k', 'v'), ('k1', 'v1'), ('k2', 'v2'), ('k3', 'v3'), ('k4', 'v4')]
    ]
}

Overwriting my dictionary values:

for k, v in my_dict.items():
     my_dict[k] = map(lambda x: dict(x), my_dict[k])

Returning…

my_dict 
{'DIC': [{'k3': 'v3', 'k7': 'v7', 'k8': 'v8'},
         {'k1': 'v1', 'k2': 'v2', 'k3': 'v3', 'k5': 'v5'},
         {'k4': 'v4', 'k9': 'v9'}],
 'DOC': [{'k': 'v', 'k1': 'v1', 'k2': 'v2', 'k3': 'v3', 'k4': 'v4'},
         {'k': 'v', 'k1': 'v1', 'k5': 'v5', 'k6': 'v6'}],
 'INFRA': [{'k1': 'v1', 'k2': 'v2', 'k3': 'v3', 'k5': 'v5'},
           {'k': 'v', 'k1': 'v1', 'k2': 'v2', 'k3': 'v3', 'k4': 'v4'}]}

When I ran my real code following the same logic I got the error:

ValueError: dictionary update sequence element #0 has length 6; 2 is required

I’ve tried to create another dictionary to receive the map() but the same error occurred. Someone could help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:04:46+00:00Added an answer on June 9, 2026 at 1:04 pm

    The dict constructor expects a sequence of 2 item subsequences (lists or tuples). At least one of subsequences contains more then two items.

    Perhaps you have missing comma (see last item):

    >>> dict([('1', 'red'),('2', 'blue'),('3' 'purple')]) # missing comma in last item
    Traceback (most recent call last):
      File "<pyshell#166>", line 1, in <module>
        dict([('1', 'red'),('2', 'blue'),('3' 'purple')]) 
    ValueError: dictionary update sequence element #2 has length 7; 2 is required
    

    Or maybe a single item instead of a tuple (again, see last item)

    >>> dict([('1', 'red'),('2', 'blue'),('purple')]) # last "tuple" has one item
    Traceback (most recent call last):
      File "<pyshell#167>", line 1, in <module>
        dict([('1', 'red'),('2', 'blue'),('purple')])
    ValueError: dictionary update sequence element #2 has length 6; 2 is required
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this (simplification): $(li).click(function{alert(test);}); <li> <input> </li> What's the best way to bind
A simplification... A building has an array of apartment objects. Each apartment has a
Here is a simplification of what I'm seeing when I try to use unique_ptr
Is there a simplification for x^(log base (1/x) of N)?
This is my code (simplification of a real-life problem): class Foo { public: void
This is the code (just a simplification of a real problem): <?php echo memory_get_usage()
I have the following XML (simplification): <?xml version=1.0 encoding=utf-8?> <TestCases> <TestCase> <Name>Test1</Name> <Result>Failed</Result> <Properties>
If we use hex because it's a simplification of binary that makes things easier
This is what I'm trying to do (this is a simplification of a real
This is quite an 'out there' question but i've been thinking about some simplification

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.