Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; 'odd': 0.07; 'subject:Why': 0.09; 'def': 0.12; 'be:': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject: \n ': 0.16; 'subject:run': 0.16; 'subject:under': 0.16; 'subject:when': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'items.': 0.19; 'code,': 0.22; 'header:User-Agent:1': 0.23; 'suggested': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'assumes': 0.31; 'relies': 0.31; 'received:84': 0.35; 'there': 0.35; 'subject:?': 0.36; 'should': 0.36; 'changing': 0.37; 'list': 0.37; 'list.': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'called': 0.40; 'dave': 0.60; 'numbers': 0.61; 'skip:n 10': 0.64; 'taking': 0.65; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'subject:have': 0.80; 'reply- to:addr:python.org': 0.84; 'angel': 0.91 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=Vd3OYjZ9 c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=0kkAYlmtguIA:10 a=CJTm3hUe6ZAA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=d1pqS0UbwCEA:10 a=fJVavL8WZ7xnQ__AOlwA:9 a=siqUZhl-yht32yrK:21 a=Q5x4kImzhhxEGvQ8:21 a=wPNLvfGTeEIA:10 X-AUTH: mrabarnett:2500 Date: Sat, 21 Sep 2013 17:18:32 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? References: <22b99b0a-598f-4500-9de9-5041c2ce2c8f@googlegroups.com> <24104d3b-ad83-4c15-bb9e-77b61a0bac78@googlegroups.com> <5398c4af-1692-4b7f-9f39-ea392d24199b@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1379780313 news.xs4all.nl 16004 [2001:888:2000:d::a6]:49773 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:54559 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 >