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

  • SEARCH
  • Home
  • 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 8883235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:45:58+00:00 2026-06-14T20:45:58+00:00

This is code in IDLE2 in python, and error. I need to include each

  • 0

This is code in IDLE2 in python, and error.

I need to include each “data” element as key and value “otro”, in an orderly manner. Well “data” and “otro” it’s list with 38 string’s, as for “dik” it’s an dictionary.

>>> for i in range(len(otro)+1):
    dik[dato[i]] = otro[i]  

Traceback (most recent call last):
  File "<pyshell#206>", line 2, in <module>
    dik[dato[i]] = otro[i]
IndexError: list index out of range
>>> 

this problem is range(0, 38)
output -> (0, 1,2,3 … 37) and it is all messy

  • 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-14T20:45:59+00:00Added an answer on June 14, 2026 at 8:45 pm

    I think something like:

    dik = dict(zip(dato,otro))
    

    is a little cleaner…


    If dik already exists and you’re just updating it:

    dik.update(zip(dato,otro))
    

    If you don’t know about zip, you should invest a little time learning it. It’s super useful.

    a = [ 1 , 2 , 3 , 4 ]
    b = ['a','b','c','d']
    zip(a,b)   #=>   [(1,'a'),(2,'b'),(3,'c'),(4,'d')] #(This is actually a zip-object on python 3.x)
    

    zip can also take more arguments (zip(a,b,c)) for example will give you a list of 3-tuples, but that’s not terribly important for the discussion here.

    This happens to be exactly one of the things that the dict “constructor” (type) likes to initialize a set of key-value pairs. The first element in each tuple is the key and the second element is the value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code below allows me to find the word error in all my files
This code gives me this error:Cannot implicitly convert type ArrayList[] to ArrayList[][] at this
This code fails on some machines: // Parse error: syntax error, unexpected '[' ...
This code produces a different output in Python 2 and Python 3 . class
I'm using python 3.2.3 IDLE and this is my code: originalList = [1, 2,
So I have some Python code that's structured something like this; class GameObject(pygame.spriteDirtySprite): def
I've been trying to get this snippet of python code to work, but to
I am trying to learn Python lists. In this code I am trying to
this is my code on python 3.2.3 IDLE: numbers = [] numbers = input((Enter
This code is the core of a much larger script that works great in

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.