# [Tutor] Me again

Chris Irish chris.irish at libertydistribution.com
Thu Aug 12 19:31:50 CEST 2004

```jason hochstein wrote:

> This is what I get when using the %.
>
> l_input=[]
>
> while True:
>     s = raw_input("Type number. Hit enter for more or type quit to
> finish: ")
>
>
>     if s == "quit":
>         break
>     else:
>          l_input.append(float(s))
>
>
> for i in l_input:
>         average = sum(l_input) / len(l_input)
>         middle = len(l_input) % 2
>
>
> print "The mean of this list is ",average
> print "The median of this list is",middle
>
> Here is what I get:
> >> The mean of this list is  5.5
> The median of this list is 0

Is the median not what you were expecting?  You also didn't show what
numbers you entered at the prompt.  However, when I run this i get the
correct avg, but the % operator you used won't return the median.
Instead you getting the value of the remainder of your division i.e.
6%2=0 , and 7%2=1.  If you want the middle value just find the length of
the list and divide by two.  But if the length isn't a even number
you'll have to find the avg of the two middle values.  Hope that
helps.......Chris

>------------------------------------------------------------------------
>
>_______________________________________________
>
>

```