#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    55
    Rep Power
    10

    Document for help with keywords?(easy)


    Hello again folks,
    I've read the documentation, but I don't really understand it. I'm hoping that some one here can direct me to a document that offers a simple explanation of the keywords I can use to get out of loops.
    I'm doing something like this:
    Code:
    while.....
         if....
         elif...
    I'm trying to break out of the first 'if' when a certain condition is met, and go back to the 'while', but i'm having a hard time with it. When the 'if' condition isn't met, the elif statement is executed, and then it should loop back to the while statement. Any suggestions appreciated!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    394
    Rep Power
    51
    Hi!

    Something like this?
    Code:
    x = 0
    while x < 10:
        if x == 3:
            pass
        elif x == 4:
            print "its 4 now"
        else:
            print x
        x += 1
    There is also continue:
    Code:
    x = 0
    while x < 10:
        x += 1
        if x == 3:
            continue
        elif x == 4:
            print "its 4 now"
            continue
        print x
    and break, which also stops the while loop:
    Code:
    x = 0
    while x < 10:
        x += 1
        if x == 3:
            break
        print x
    Hope this helps.

    Regards, mawe
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    55
    Rep Power
    10

    turns out it's variable settings


    Very nice, thank you! It turns out my real problem is that min(s) and max(s) aren't resetting themselves like they should. I think the library I was given has a bug in it.
    Thanks for your help tho!
    Originally Posted by mawe
    Hi!

    Something like this?
    Code:
    x = 0
    while x < 10:
        if x == 3:
            pass
        elif x == 4:
            print "its 4 now"
        else:
            print x
        x += 1
    There is also continue:
    Code:
    x = 0
    while x < 10:
        x += 1
        if x == 3:
            continue
        elif x == 4:
            print "its 4 now"
            continue
        print x
    and break, which also stops the while loop:
    Code:
    x = 0
    while x < 10:
        x += 1
        if x == 3:
            break
        print x
    Hope this helps.

    Regards, mawe

IMN logo majestic logo threadwatch logo seochat tools logo