1

I have two lists with just one element as follows(each of these two lists always contains only one element):

Vnew = [600]
Newoints2 = [(2447,3480)]

I'm trying to bring both of them together using the following code sample:

for i, key in enumerate(Vnew2):
  pos3[key] = newpoints2[i]

But this returns an error as IndexError: list assignment index out of range

I actually did this one for other lists which have more than one element. It worked fine and got the output as {0:(1245,674),1:(2457,895),...}

Can someone find the mistake here?

3
  • 3
    Seems like pos3 is a list when it should be a dict. Commented Jun 27, 2018 at 20:15
  • Post what pos3 is Commented Jun 27, 2018 at 20:18
  • @Farhan, Thanks for pointing me out the mistake. I fixed that with pos3={}. Commented Jun 27, 2018 at 20:24

1 Answer 1

2

It looks like you are trying to concatenate the lists into a new list. You don't always need to enumerate through the list.

You will be able to do this by Vnew + Newoints2

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.