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 6079153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:54:52+00:00 2026-05-23T10:54:52+00:00

I am attempting to initialize a list and keep getting the index out of

  • 0

I am attempting to initialize a list and keep getting the index out of range:

self.nodes = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]]

When I run this code:

for i in range(self.rows):
            for j in range(self.columns):
                if self.GRID[i][j] == 0:
                    self.walkable.append(Node(j * self.cellSize, i * self.cellSize))
                    self.isWalkable = True
                if self.GRID[i][j] == 1:
                    self.unwalkable.append(Node(j * self.cellSize, i * self.cellSize))
                    self.isWalkable = False
                if self.GRID[i][j] == 2:
                    self.player = Node(j * self.cellSize, i * self.cellSize)
                    self.isWalkable = True
                if self.GRID[i][j] == 3:
                    self.npc = Node(j * self.cellSize, i * self.cellSize)
                    self.isWalkable = True

                self.nodes[i][j] = Node(j, i)
                self.nodes[i][j].setWalkable(self.isWalkable)

The error I get is:

self.nodes[i][j] = Node(j, i)
IndexError: list assignment index out of range
  • 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-05-23T10:54:53+00:00Added an answer on May 23, 2026 at 10:54 am

    What is Node() ?

    >>> nodes = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]]
    >>> nodes[0][0] = 5
    Traceback (most recent call last):
      File "<interactive input>", line 1, in <module>
    IndexError: list assignment index out of range
    >>> nodes[0].append(5)
    >>> nodes
    [[5], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting to print out a list of values from 2 different variables that are
I am attempting following code to create multiple instances of a class at run-time
I'm attempting to initialize a multicore solr server using Solr 3.5 and I'm getting
Attempting to use the data series from this example no longer passes the JSONLint
When attempting to call functions in math.h , I'm getting link errors like the
I have an unordered list, and I'm attempting to append a few links to
I have a constructor attempting to initialize a field in a base class. The
I am attempting to find a way to force Java to load/initialize an enumerated
Attempting to follow this Java tutorial . About 63 pages in, you are instructed
I am attempting to use namespaces to better organize my sites very complicated code.

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.