I'm trying to figure out a way to find if there are duplicates in an array. My idea was to take the array as 'a' and make a second array as 'b' and remove the duplicates from 'b' using 'set' and then compare a to b. If they're different then it will print out 'duplicates found'. The problem is that even after trying different arrays, some with duplicates some without, that 'b' rearranges the numbers. Here's an example:
-
-
a='1934, 2311, 1001, 4056, 1001, 3459, 9078'
-
b=list(set(a))
-
if a != b:
-
print "duplicates found"
-
else:
-
print "nothing found"
-
-
Is there a simpler way to find if there are duplicates?
Thanks