[Tutor] How to "grab" a Word Update!Im gettin there!!
Danny Yoo
dyoo@hkn.eecs.berkeley.edu
Tue Jul 15 17:32:01 2003
On Tue, 15 Jul 2003, Paul Hickey wrote:
> Hi, with help from you , I've got this far,
>
> s = raw_input("What do you like to do")
> if s.find('music')
> print "So you like music then!"
> elif s.find('golf')
> print "You like golf, boring!!"
> elif s.find('walking')
> print " Us computers can't walk!"
>
> This works fine when only one argument is present, naturally im trying
> to push it!!!!! Problem is it returns the first print statement whatever
> you enter,I've played with this with no joy as yet Thanks for your help
> so far. Sorry to be a pest.... Paul
Hi Paul,
No problem. *grin* Glad to see that you're getting closer.
The condition that you're checking:
elif s.find('walking')
^^^^^^^^^^^^^^^^^
is almost right. To fix that problem, take a look again at that message I
sent about find():
http://mail.python.org/pipermail/tutor/2003-July/024021.html
Remember that find() isn't giving a "yes/no" sort of answer: it's giving
the position where it can find 'walking'. We need to do something extra
with that result to turn it into a yes/no "boolean" thing.
Good luck!