[Tutor] Understanding error in recursive function
Alan Gauld
alan.gauld at btinternet.com
Sat Apr 16 18:48:37 EDT 2016
On 10/04/16 19:36, Peter Otten wrote:
> Alan Gauld wrote:
>
>> or a slightly sneaky but faster version:
>>
>> def howMany(aList):
>> return aList.index(aList[-1]) + 1
>
> Sorry, but this isn't "slightly sneaky", this is outright wrong.
> I fails for both empty lists and lists with duplicate entries.
Oops, quite right. Sorry.
Just back from a weeks vacation hence the delayed response...
Also why you'll see a bunch of delayed messages from moderation arriving...
--
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