[Tutor] Please help, the program is not behaving as I want

Joel Goldstick joel.goldstick at gmail.com
Tue May 17 20:34:39 CEST 2011


On Tue, May 17, 2011 at 12:54 PM, I. Dooba <idooba at gmail.com> wrote:

> Thanks, Joel Goldstick
>
> There is no error message.
> But the program is returning incomplete or too many characters.  For
> example, instead of "Halal" it will return "l Hala"
> or "nol" depending on the length of the word the user inputs.
>
> Since I can't predict the words the user will search for, I'm finding it
> difficult to tackle the problem.
> ___________
> I. Dooba
> Hybrid Intelligence & Digital Infrastructure Research Group
> Universiti Teknologi PETRONAS
> +6014 644 5086
> ibraheem_g01318 at utp.edu.my
>
>
> I haven't read the book you are using, so I don't know what lessons they
are trying to teach in this example.  However, you should be aware that if
you read the input into a variable first, then do the .find() method
separately on the next line, you can later find out how long the word your
user typed (google python length of string if you don't know how).  Use this
length value to add to the start of your index so that you can start your
result at the beginning of Halal or Haram.  Then at least, if the word is in
your list you will get the answer you expect.

> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
Joel Goldstick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110517/5139554d/attachment.html>


More information about the Tutor mailing list