if statements with or w/o else statements

Bart Nessux bart_nessux at hotmail.com
Mon Feb 23 08:31:03 EST 2004


Should an if statement have a corresponding else statement? Or, is it OK 
to have an if statement by itself. For completeness, it seems the two 
should be together, but from experience I know that a if statement by 
itself works just fine. Below is an example:

if x >=0:
    DO SOMETHING

Would it be better, or perhaps more complete, written like this:

if x >=0:
    DO SOMETHING
else:
    DO SOMETHING ELSE




More information about the Python-list mailing list