[Tutor] Question related to for loops
Alan Gauld
alan.gauld at yahoo.co.uk
Fri Mar 19 19:27:05 EDT 2021
On 19/03/2021 21:54, Dennis Lee Bieber wrote:
> Besides the fact that it processes the input list TWICE, once each for
> odd and even values, I think you meant for
>
> i for i in x if
>
> to be
>
> 1 for i in x if
>
> You want a count of how many even/odd entries there are, not a sum
According to his original post he does actually want the sum.
It's an odd request but its what both of his examples generate.
And he specifically said:
>>> consider a problem of finding sum of even and odd numbers
>>> inside a list..
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list