[Tutor] Not workin!

Rich Lovely roadierich at googlemail.com
Wed Sep 30 00:18:28 CEST 2009


2009/9/29 Corey Richardson <kb1pkl at aim.com>:
> I got suggested to use this format for my code, as it was shorter and
> prettier. But It dun work!
> if wellness != ["Well","Fine","Good", "OK", "ok", "Ok", "Great", "Awesome",
> "Epic"]:
>   print "Oh, I'm sorry you are not feeling well."
>   areYouOk = raw_input("I guessed correct, right?")
>   if areYouOk != ["yes", "yep", "yup", "yea"]:
>       print "Oh, thats to bad. Things will be better"
>   else  :
>       print "Oh, I'm glad your ok then!"
> It just prints the "Oh, I'm sorry you are not feeling well.", and then when
> you reply, it says "Oh, thats to bad. Things will be better"/
> Ahhh! Why does it be do this? And there is no error, btw.
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>

You are testing a string, returned by raw_input() for (in)equality to
a list.  You shouldn't be suprised at your results. You need to be
testing (I assume) for membership of the list, i.e. whether the string
is /in/ the list.

-- 
Rich "Roadie Rich" Lovely

There are 10 types of people in the world: those who know binary,
those who do not, and those who are off by one.


More information about the Tutor mailing list