Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • I think the names.remove(name) might be a O(n) operation, which would make this a O(n^2) algorithm. Commented Oct 4, 2008 at 3:28
  • 1
    I would personally write my while expression as item < len(names), just in case I screwed up the logic inside the loop. (even though it doesn't look like you did) Commented Oct 8, 2008 at 0:31
  • It's probably more efficient to use del names[item] or names.pop(item) than names.remove(name). That's much less likely to be O(n), although I don't know the actual internals of how it works. Commented Nov 5, 2008 at 13:11