I'm doing a Codewars challenge for finding the unique value in a list and I'm having trouble finding the good way to do this process at my skill level.
This solution works for tests but times out the attempt (12000ms).
def find_uniq(arr):
for element in arr:
if arr.count(element) == 1:
return element
link to the exercise: https://www.codewars.com/kata/585d7d5adb20cf33cb000235/train/python
.remove
inside a loop for performance reasons (hence the timeout) and because it is very easy (for beginners AND experts) to write incorrect code with it. It's better to just create a new list if you have to.