Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject: + ': 0.07; 'string': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'jan': 0.12; 'code?': 0.16; 'hint': 0.16; 'none.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'so.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'hey': 0.18; 'bit': 0.19; 'not,': 0.20; 'example': 0.22; 'header :User-Agent:1': 0.23; 'guys': 0.24; 'code:': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'subject:) ': 0.29; "i'm": 0.30; 'such.': 0.31; 'wright': 0.31; 'supposed': 0.32; 'run': 0.32; 'problem': 0.35; 'test': 0.35; 'doing': 0.36; 'should': 0.36; 'needed': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'most': 0.60; 'received:173': 0.61; 'finally': 0.65; 'here': 0.66; 'natural': 0.68; 'discovered': 0.83; 'received:fios.verizon.net': 0.84; 'subject:here': 0.84; 'subject:Lists': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Jan Reedy Subject: Re: (Learner-here) Lists + Functions = headache Date: Sun, 05 May 2013 21:30:25 -0400 References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1367803836 news.xs4all.nl 15888 [2001:888:2000:d::a6]:51400 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44793 On 5/5/2013 8:59 PM, Bradley Wright wrote: > Hey guys and gals doing this tutorial(codecademy) and needed a bit help from the experienced. > > I'm writing a function that takes a list(one they supply during runtime) > here's what my function is supposed to do Do they supply an example so you can test both your comprehension and code? I think most specs given in natural language need such. > 1. for each instance of the string "fizz" make a count > 2. Finally return that count Did you create an example problem to test your code? If not, do so. Did you run your function with example data? If not, do so. > here's my code: > > def fizz_cout(x): > count = 0 > for item in x: > while item == "fizz": > count += 1 > return count Here is hint as to some of what needs to be improved: this function will return either 1 or None. You should have discovered that by testings. -- Terry Jan Reedy