[Tutor] taking support of strings in solving numerical problems

Alan Gauld alan.gauld at yahoo.co.uk
Mon Oct 26 04:06:31 EDT 2020


On 26/10/2020 04:55, Cameron Simpson wrote:

>> def ser_gen(no, order):
>>    f_no = no
>>    for i in range(order):
>>        yield f_no
>>        f_no = f_no*10 + no
>>
>> all(ser_gen(9, -3))     Returns True that says, there is an empty iterable
>> inside all( )
> 
> Returns True for me, too. Which is expected behaviour.
> 
> It is not clear to me what your objection is about.

To be honest it surprised me too. I expected the function to fall
off the bottom and return none. But in fact it raises a
StopIteration instead, which all() interprets as an empty sequence.

-- 
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