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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:46:38+00:00 2026-05-29T15:46:38+00:00

Let’s pretend (since it’s true) that I have a Python (3) script that needs

  • 0

Let’s pretend (since it’s true) that I have a Python (3) script that needs to iterate over a 2D array (any length, but each element is just an array of 2 ints, as per the list below).

linCirc  = [[1,10],
            [2, 1],
            [0, 2],
            [2, 2],
            [2, 3],
            [2, 4],
            [2, 0],
            [2, 5]]

I want to iterate over this lovely thing recursively so that

for element in linCirc:
    if element[0] == 0:
        # skip element[1] elements

Essentially, all I need to know is the best way to loop over linCirc, and then when certain conditions are met, instead of going from linCirc.index(element) to linCirc.index(element) + 1, I can control the skip, and skip zero or more elements. For instance, instead of going from [0, 2] to [2, 2], I could go from [0, 2] to [2, 4]. Is this the best way to do this? Should a for loop be involved at all?

For the curious: This code is intended to linearize an electric circuit so that any circuit (with limited components; say, just resistors and batteries for now) can be represented by a 2D array (like linCirc). I will post my full code if you want, but I don’t want to clog this up with useless code.

  • 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-29T15:46:39+00:00Added an answer on May 29, 2026 at 3:46 pm
    index = 0
    while index < linCirc.length:
       if linCirc[index][0] == 0:
           index = index + linCirc[index][1]
       else:
           index = index + 1
    

    Hopefully this provides the functionality you’re looking for. Obviously you’ll have to add some useful code to this – it just runs from start to end of the array. It may also be helpful to add an index check, to make sure it doesn’t run out of bounds when it encounters [0, i] less than i elements from the end of the array.

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

Sidebar

Related Questions

Let me try to explain what I need. I have a server that is
Let's say that we have an ARGB color: Color argb = Color.FromARGB(127, 69, 12,
Let's say I have multiple requirements for a password. The first is that the
Let's say that I have a date in R and it's formatted as follows.
Let's suppose I have a Discussion model, and that a discussion can be tagged.
Let's say that I have a set of relations that looks like this: relations
Let's say I have a javascript array with a bunch of elements (anywhere from
Let's say that I have a binary that I am building, and I include
Let's say that I have classes like this: public class Parent { public int
Let's say I'm creating an OpenGL game in C++ that will have many objects

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.