Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Python (http://www.programmingforums.org/forum43.html)
-   -   Branching&loops problem (http://www.programmingforums.org/showthread.php?t=10371)

commodore Jun 15th, 2006 4:57 AM

Branching&loops problem
 
I have some if and elif statements that I use multiple times so I put them in a def. Now I have a while loop whic start with the defdfunction() and then has elif statements (because the if statement is in the defdfunction) but python says that the firs elif in the while loop is an error.

Here's an example:
http://rafb.net/paste/results/ZXY1lI53.html

Arevos Jun 15th, 2006 6:30 AM

elif and else statements are subsections of an if block. You can't move the if statement away from the elif blocks.

You probably want something like:
:

if something:
    ...
else:
    while whatever:
        if first_elif_condition:
            ...
        elif second_elif_condition:
            ...



All times are GMT -5. The time now is 8:03 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC