Python Forum
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Outer loop not running
#1
Hi

I'm working on something and it has a nested while loop. It seems like only the inner loop is running and only once;

Code:

def answer(x, y):

    idbadge = [[0 for i in range(x)] for i in range(y)]

    row = 0
    col = 0
    a = 1

    #################Detemine number of cells###############
    count = 0
    counter = 0
    i=0
    a=0
    while (a < x):
        i = i + 1
        a = a + i
        count = i
        counter = i
        print("Count is " + str(count));
        print("Counter is " + str(counter))


    row = 0
    col = 0
    a = 1
    #n = 0
    ##############Build Matrix###############

    row = 0
    col = 0
    a = 1
    t = 2

    print("Count: " + str(count))


    while col < count:
        while row < count:

            print("Row:" + str(row))
            print("Col:" + str(col))
            print("ID BADGE" + str(a))
            idbadge[row][col] = a
            row = row + 1
            a = a + row

        col = col + 1
        #t = t + 1
        #a = t


    ###############Print Out###############

    #print top row (row 0)
    #print second top row
    #continue printing until row is equal to 4


answer(10,10)
Reply


Messages In This Thread
Outer loop not running - by ted_gress - Aug-25-2018, 05:08 AM
RE: Outer loop not running - by Larz60+ - Aug-25-2018, 07:43 AM
RE: Outer loop not running - by volcano63 - Aug-25-2018, 07:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pandas Outer merge skollu826 2 369 Apr-20-2024, 06:28 PM
Last Post: deanhystad
  help RuntimeError: no running event loop marpaslight 5 4,127 Oct-18-2022, 10:04 PM
Last Post: marpaslight
  can Inner Class reference the Outer Class's static variable? raykuan 6 6,344 Jul-01-2022, 06:34 AM
Last Post: SharonDutton
  bleak library RuntimeError: This event loop is already running alice93 3 4,347 Sep-30-2021, 08:06 AM
Last Post: alice93
  loop running indefinitely shantanu97 6 2,768 Sep-29-2021, 08:03 PM
Last Post: deanhystad
  Running A Loop Until You See A Particular Result knight2000 6 32,144 Sep-04-2021, 08:55 AM
Last Post: knight2000
  Running loop at specific frequency mdsousa 3 6,212 Apr-21-2021, 11:22 AM
Last Post: jefsummers
  RuntimeError: This event loop is already running newbie2019 2 7,095 Sep-30-2020, 06:59 PM
Last Post: forest44
  Unindent does not match any outer intendation level -error MaartenRo 3 2,386 Jun-28-2020, 11:46 AM
Last Post: MaartenRo
  HELP! unindent does not match any outer indentation level blackjesus24 2 2,079 Jan-29-2020, 08:00 AM
Last Post: blackjesus24

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020