Nested if's

Mike Steed MSteed at altiris.com
Fri Oct 15 11:49:12 EDT 1999


> From: geojempty at aol.com [mailto:geojempty at aol.com]
> Sent: Friday, October 15, 1999 9:21 AM
> To: python-list at python.org
> Subject: Nested if's
> 
> 
> I'm brand new to Python, though I chose it for my CGI 
> programming because of
> it's similarity to the language I use at my day-job: the Progress 4GL
> 
> Enough for intros.  I'm having a problem nesting if 
> statements.  I'm defining a
> function, and my syntax checks fine, until I try the following:
> 
> if digit > 0:
>   if digit = 5:
>     variable = variable + whatever

As it stands, the 2nd line will raise a SyntaxError.  It's doing an
assignment, not a comparison.  It's an error because assignment is not an
expression in Python.  Instead try:

  if digit == 5:

--
M.




More information about the Python-list mailing list