[Tutor] what's wrong with this code

Michael P. Reilly arcege@shore.net
Wed, 28 Feb 2001 19:59:12 -0500 (EST)


> What's wrong with this code?  I don't understand. Please help.
> 
> input("What is the temperature of the spam?") = temperature
> 
>     if temperature > 50:
>         print "The salad is properly cooked."
>     else:
>         print "Cook the salad some more."

Quickly, I see two things.  The first is basic to programming so it may
take newbies a little to understand.

Assignment statements consist a left-hand-side and a right-hand-side.
The right-hand-side is the value to be assigned and the left-hand-side
is the place being "saved" to.  In your code above, the place you are
saving the value to, "temperature" is on the right.

The second could be just a problem with the mailer.  But in Python,
indentation is important.  The "if/else" statement must line up
with the "input" assignment.

temperature = input("What is the temperature of the spam?")
if temperature > 50:
    print "The salad is properly cooked."
else:
    print "Cook the salad some more."

The statements just after "if" and "else" would be indented, but the
"if" and "else" and "temperatre = ..." lines are to be in the same
column.

  -Arcege

-- 
------------------------------------------------------------------------
| Michael P. Reilly, Release Manager  | Email: arcege@shore.net        |
| Salem, Mass. USA  01970             |                                |
------------------------------------------------------------------------