Problems using samples
Mark McEahern
marklists at mceahern.com
Wed Jun 26 13:22:30 EDT 2002
> 6 if x = y:
This statement assigns (binds) the value of y to the name x. I assume what
you want to do is test for equality. If so, you should use the equality
operator, not the assignment operator:
if x == y:
By the way, if you want to make it easier to help you in the future, please
post an interactive session that demonstrates the error you're experiencing;
i.e.,
>>> x = 8
>>> y = 4
>>> v = x - y
>>> if x = y:
File "<string>", line 1
if x = y:
^
SyntaxError: invalid syntax
This is one of the beauties of Python--you should take advantage of it.
Admittedly, Python's error is cryptic, but the ^ clues you in to the fact
that it has something to do with the equals sign.
// m
-
More information about the Python-list
mailing list