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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:33:17+00:00 2026-05-26T22:33:17+00:00

I am using a nested for loop to draw a grid of 10 rows

  • 0

I am using a nested for loop to draw a grid of 10 rows of rectangles and 10 columns of rectangles (100 total):

gridTiles = []

for r in range(totalSpaces):
    for c in range(totalSpaces):
        tiles = Rectangle(Point(borderSet + r * spaceSize, borderSet + c * spaceSize), Point(borderSet + (r + 1) * spaceSize, borderSet + (c + 1) * spaceSize))
        tiles.setWidth(2)
        tiles.draw(board)
        gridTiles.append(tiles)

I know that the Rectangle does not support indexing (as shown in the TypeError I get), but I need to be able to access one specific rectangle later in my code.

Is there a way to somehow index each rectangle, so I can do something along the lines of gridTiles[3][7] later (although, of course, the way it is now, it will not allow that)? And, incidentally, I currently do not know the things that are like __something__, so I can’t easily use any method that’s done like that.

  • 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-26T22:33:18+00:00Added an answer on May 26, 2026 at 10:33 pm

    Make gridTiles have nested lists:

    gridTiles = []
    
    for r in range(totalSpaces):
        row = []
    
        for c in range(totalSpaces):
            tiles = Rectangle(Point(borderSet + r * spaceSize, borderSet + c * spaceSize), Point(borderSet + (r + 1) * spaceSize, borderSet + (c + 1) * spaceSize))
            tiles.setWidth(2)
            tiles.draw(board)
    
            row.append(tiles)
        gridTiles.append(row)
    

    Now you should be able to index like you want:

    gridTiles[0][0]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a view of isometric tiles using this simple nested loop: const TILE_WIDTH:Number
I have a nested loop that I'm using foreach, DoSNOW, and a SNOW socket
In the following C code I am using OpenMP in a nested loop. Since
I'm trying to loop through a row of an arraycollection using nested repeater; <mx:Repeater
I'm performing a nested loop in python that is included below. This serves as
I am currently using groupby with a foreach loop to show a list of
It is often useful to implement algorithms using nested array operations. For example, to
I have a stored procedure below. In it is a nested loop. Instead of
I'm working on a homework assignment where I must manually optimize a nested loop
I've a program that does Block Nested loop join ( link text ). Basically

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.