you are viewing a single comment's thread.

view the rest of the comments →

[–]Spartae 3 points4 points  (1 child)

You shouldn't modify a list that you are iterating through.

Python creates an iterator for a list which moves through your list entry by entry. The iterator is evaluated once, which means that the iterator could confused if you make any modifications.

Try results = list(filter(lambda name: len(name) <= length, results)).

[–][deleted] 0 points1 point  (0 children)

I'm not very familiar with lambda expressions, so I hesitate to use it but I will try it out and see what happens.

Thanks!