Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Non-unique Elements: a simple solution solution in Clear category for Non-unique Elements by wojtask98
def checkio(data):
#new list declaration
no_unique_numbers = []
for element in data:
#adding only non-unique numebrs to the new list
if data.count(element) != 1:
no_unique_numbers.append(element)
#return the list without unique numebrs
return no_unique_numbers
if __name__ == "__main__":
#These "asserts" using only for self-checking and not necessary for auto-testing
assert list(checkio([1, 2, 3, 1, 3])) == [1, 3, 1, 3], "1st example"
assert list(checkio([1, 2, 3, 4, 5])) == [], "2nd example"
assert list(checkio([5, 5, 5, 5, 5])) == [5, 5, 5, 5, 5], "3rd example"
assert list(checkio([10, 9, 10, 10, 9, 8])) == [10, 9, 10, 10, 9], "4th example"
print("It is all good. Let's check it now")
Oct. 14, 2017