[Tutor] help

Daniel Yoo dyoo@hkn.eecs.berkeley.edu
Mon, 9 Oct 2000 20:05:31 -0700 (PDT)

On Mon, 9 Oct 2000, Richard E. Doksa wrote:

> hi im new to programming and cant find help anywhere where i live i
> was wondering can anyone tell me what is wrong with this program i
> wrote. it is only a program to answer a simple question.
> input = feline
> print raw_input("what kind of animal is a cat?")
> if input == feline:
>  print "thats right!"
> if input != feline:
>  print "try again"

The only problem is that Python can't tell that you literally mean the
word "feline".  For all it knows, you might have a feline variable.  
You're probably getting a NameError, which is a symptom of accidently
forgetting about this.

To make it unambiguous, you should quote 'feline' as a string:

    if input == 'feline':
        print "that's right!"
    if input != 'feline':
        print "try again"

Other things to point out: you probably don't want to use 'input' as a
variable name, since there's already an input() function (similar to
raw_input).  It's usually safer to give a distinctive name to your
variables... hmmm... a good name might be 'animal'.  Timothy Wilson caught
a few other things in his response, so take a look at his program for
other things.

If you have any questions, please feel free to ask us; we'll be glad to
help.  Good luck with your learning!