Loop and the list
Tjarko de Jong
tjarko at dutlbcz.lr.tudelft.nl
Fri May 14 10:37:02 EDT 2004
On 14 May 2004 13:46:46 GMT, Krzysztof Szynter
<dygimailNo at SPAMpoczta.fm> wrote:
>Hi all
>
>Have got a big problem. This is my code:
>def maxvalue(TY): #gets an index of the max value in the TY list
> max = 0
indexMax = -1
> for i in range(0,len(TY)):
> if (max<TY[i]):
> # max = i
max=TY[i]
indexMax=i
> print TY[i],max
> continue
> # return max
return indexMax
>I don't understand why function maxvalue returns "9". When i start a
>program and check TY list in 'first main point', the max value has an index
>0'. Then putting the list into the function maxvalue, gives me the index
>'9'. ;--/
>
>Where is the mistake?
>
>ps
>Apologise for the Polish text's, in the code. I'll answer for any question.
More information about the Python-list
mailing list