3 ms·
You deleted your other comment but you've now written the comprehension version twice (the second version added in an edit when it was pointed out the first one
by pvg 9y ago
You deleted your other comment but you've now written the comprehension version twice (the second version added in an edit when it was pointed out the first one isn't equivalent to the loop) and neither of them actually work. So perhaps writing the comprehension version is neither as clear or simple as you suggest.
- crdoconnor 9y agoIt was sloppy copying and pasting of a working expression. I think it's pretty clear I meant to write this: def contains_duplicate(array): return any(len([y for y in array if x == y]) > 1 for x in array) Or were you saying that this ^^ doesn't work?