Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44793
| From | Terry Jan Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: (Learner-here) Lists + Functions = headache |
| Date | 2013-05-05 21:30 -0400 |
| References | <ed7e2a6d-ad84-49b1-afae-6d1516fc1130@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1314.1367803836.3114.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
(Learner-here) Lists + Functions = headache Bradley Wright <bradley.wright.biz@gmail.com> - 2013-05-05 17:59 -0700
Re: (Learner-here) Lists + Functions = headache alex23 <wuwei23@gmail.com> - 2013-05-05 18:21 -0700
Re: (Learner-here) Lists + Functions = headache Bradley Wright <bradley.wright.biz@gmail.com> - 2013-05-05 18:24 -0700
Re: (Learner-here) Lists + Functions = headache Bradley Wright <bradley.wright.biz@gmail.com> - 2013-05-05 18:30 -0700
Re: (Learner-here) Lists + Functions = headache Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-06 10:25 +0100
Re: (Learner-here) Lists + Functions = headache Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-06 01:31 +0000
Re: (Learner-here) Lists + Functions = headache Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-06 01:48 +0000
Re: (Learner-here) Lists + Functions = headache Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-05 21:30 -0400
Re: (Learner-here) Lists + Functions = headache 88888 Dihedral <dihedral88888@googlemail.com> - 2013-05-05 22:39 -0700
Re: (Learner-here) Lists + Functions = headache Chris Angelico <rosuav@gmail.com> - 2013-05-06 17:32 +1000
csiph-web