if - else

Christopher Koppler klapotec at chello.at
Thu Nov 27 17:28:29 EST 2003


On Thu, 27 Nov 2003 21:43:31 GMT, Jeff Wagner <JWagner at hotmail.com>
wrote:

>On Thu, 27 Nov 2003 20:33:05 GMT, "Andrew Koenig" <ark at acm.org> wrotf:
>
>>> True, also someone's being careless with their code.
>>>
>>>     if SumOfNumbers = 10:
>>>         SumOfNumbers = 1
>>>
>>> What happens with that? :)
>>
>>In Python?  Easy -- it doesn't compile.
>>
>
>Ok, why won't it compile? I thought the standard if statement went like this -
>
>if Condition:
>    suite
>
>so why won't the above work? I realize it's not the best way to accomplish what I want to do, I'm
>just trying to learn why it is an incorrect if statement so I know for the future.

It does assignment (=) instead of comparison (==) in the condition,
which is illegal in Python.


--
Christopher




More information about the Python-list mailing list