Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 28th, 2008, 04:08 PM
Newbie
 
Join Date: Jun 2007
Posts: 15
Default 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
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles