Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

MRAB python at mrabarnett.plus.com
Sat Sep 21 12:18:32 EDT 2013


On 21/09/2013 13:53, Dave Angel wrote:
[snip]
> Taking Steven's suggested code, and changing it so it uses a COPY of the
> global list;
>
> def median():
>      # Relies on the global variable called List.
>      # assumes there is at least one number in that list
>      numbers = List.sorted()

That should be:

      numbers = sorted(List)

>      n = len(numbers)
>      if n % 2 == 1:
>          # Odd number of items.
>          return numbers[n//2]
>      else:
>          a = numbers[n//2 - 1]
>          b = numbers[n//2]
>          return (a + b)/2.0
>




More information about the Python-list mailing list