filter() + simple program not outputting
Fredrik Lundh
fredrik at pythonware.com
Mon Jul 26 17:27:22 EDT 1999
More information about the Python-list mailing list
Mon Jul 26 17:27:22 EDT 1999
- Previous message (by thread): filter() + simple program not outputting
- Next message (by thread): filter() + simple program not outputting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
(posted and mailed) Joyce Stack <joyce at netcard.com> wrote: > New to python but not to programming...can someone tell me why this > simple program is not outputting when i run from the BASH prompt....any > pointers would be helpful...thanking you in advance.... > > Joyce > > #!/usr/bin/env python > > def f(x): > return x%2 != 0 and x%3 != 0 > filter(f, range(2, 25)) > f( ) dunno. what is it supposed to do? there's no print statement in there, nor anything else related to printing. and while "f" is declared, it's never called. and that function looks a bit strange -- it starts out by returning to the caller, and thus never runs any code. but it's close. could the following be what you tried to do: --- cut --- #!/usr/bin/env python def f(x): return x%2 != 0 and x%3 != 0 print filter(f, range(2, 25)) --- cut --- note the use of indentation -- things at the left margin are executed when you run this as a script ("def" is a statement too!). </F>
- Previous message (by thread): filter() + simple program not outputting
- Next message (by thread): filter() + simple program not outputting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list