[Tutor] Understanding error in recursive function

Peter Otten __peter__ at web.de
Sun Apr 10 14:36:43 EDT 2016


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.





More information about the Tutor mailing list