Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 15th, 2006, 3:57 AM   #1
commodore
Programmer
 
Join Date: Nov 2005
Location: Estonia
Posts: 97
Rep Power: 0 commodore is an unknown quantity at this point
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
commodore is offline   Reply With Quote
Old Jun 15th, 2006, 5:30 AM   #2
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
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:
            ...

Last edited by Arevos; Jun 15th, 2006 at 5:55 AM.
Arevos is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:58 PM.

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