nested loops and goto line

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eddiefisher41
    New Member
    • Jun 2007
    • 15

    nested loops and goto line

    Hello.
    I have a quick question about loops, i just cant seem to get it to work correctly. the code generates a tuple containing a set of numbers. The if statement is designed to catch tuples that are not valid, if its not a valid one then i need it to go back to line 1 and regenerate the tuple.

    def function():
    ............... ............... # line1
    ............... ............... # line2
    ............... ............... # line3
    ............... ............... # line4

    if (logical statement = true):
    goto line 4

    Now rather than putting those 4 lines into another function and messing up my counter scheme id rather use some kind of loop structure.
    I have tried using a while loop:

    while (logical statement = true):
    ............... ............... # line1
    ............... ............... # line2
    ............... ............... # line3
    ............... ............... # line4

    But this comes problematic when it needs to exit the loop and gives infinate loops, YUK!

    Any help would be much appreciated.
    Ed
Working...