[Tutor] exercise correct ??

Walter Prins wprins at gmail.com
Mon Sep 6 21:55:31 CEST 2010


Hi Roelof,

On 6 September 2010 18:32, Roelof Wobben <rwobben at hotmail.com> wrote:

>        >>> index_of(5, (1, 2, 4, 5, 6, 10, 5, 5), 4)
>       6
>
> But in that tuple 5 is on position 3.
>
> Is the exercise here wrong ?
>
>

Not neccesarily...  I notice that the call is similar to the previous test
case, but has an extra parameter "4",  and that but that tuple that's being
searched contains other 5's.  If the extra parameter is interpreted as a
"starting index", then the next index of "5" starting at position 4, would
indeed be 6.  If my guesstimated intention of the test paramters is correct
then there's nothing wrong with the excercise/test and your implementation
of index_of needs to be enhanced to properly handle this extra parameter/new
test case.

Walter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100906/09337390/attachment.html>


More information about the Tutor mailing list