[Tutor] if else

Paul Sidorsky paulsid@shaw.ca
Wed, 22 May 2002 12:00:24 -0600


Terje Johan Abrahamsen wrote:

> if a = 1 :

> But, it doesn't work. When I try to run it, I get the following response:
> "Failed to run script - syntax error - invalid syntax" What do I do wrong?

You need to use a double-equals, ==, to "test" a value.  This is to
clearly differentiate it from = which is used for assignment.  So your
second example becomes:

a = 1
if a == 1 :
    print "Yes"
else :
    print "No"

-- 
======================================================================
Paul Sidorsky                                          Calgary, Canada
paulsid@shaw.ca                        http://members.shaw.ca/paulsid/