fork(2) download
  1. #Your optional code here
  2. #You can import some modules or create additional functions
  3.  
  4.  
  5. def checkio(data):
  6. #Your code here
  7. #It's main function. Don't remove this function
  8. #It's used for auto-testing and must return a result for check.
  9. #valueIndicesMapping = {}
  10. nonUniqueList = []
  11. for element in data :
  12. if data.count(element) > 1:
  13. nonUniqueList.append(element)
  14. #replace this for solution
  15. return nonUniqueList
  16.  
  17. #Some hints
  18. #You can use list.count(element) method for counting.
  19. #Create new list with non-unique elements
  20. #Loop over original list
  21.  
  22.  
  23. if __name__ == "__main__":
  24. #These "asserts" using only for self-checking and not necessary for auto-testing
  25. '''assert isinstance(checkio([1]), list), "The result must be a list"
  26. assert checkio([1, 2, 3, 1, 3]) == [1, 3, 1, 3], "1st example"
  27. assert checkio([1, 2, 3, 4, 5]) == [], "2nd example"
  28. assert checkio([5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5], "3rd example"
  29. assert checkio([10, 9, 10, 10, 9, 8]) == [10, 9, 10, 10, 9], "4th example"
  30. '''
  31. print checkio([1, 2, 3, 4, 5])
  32. # your code goes here
Success #stdin #stdout 0.01s 7692KB
stdin
Standard input is empty
stdout
[]