sakiir

Untitled

Sep 23rd, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. #Your optional code here
  2. #You can import some modules or create additional functions
  3.  
  4.  
  5. def checkio(data):
  6.     c = 0
  7.     i=0
  8.     ret = []
  9.     for i in range(len(data)):
  10.         for j in range(len(data)):
  11.             if(i != j and data[i] == data[j]):
  12.                 ret.append(data[i])
  13.     return ret
  14.  
  15. #Some hints
  16. #You can use list.count(element) method for counting.
  17. #Create new list with non-unique elements
  18. #Loop over original list
  19.  
  20.  
  21. if __name__ == "__main__":
  22.     #These "asserts" using only for self-checking and not necessary for auto-testing
  23.     assert isinstance(checkio([1]), list), "The result must be a list"
  24.     assert checkio([1, 2, 3, 1, 3]) == [1, 3, 1, 3], "1st example"
  25.     assert checkio([1, 2, 3, 4, 5]) == [], "2nd example"
  26.     assert checkio([5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5], "3rd example"
  27.     assert checkio([10, 9, 10, 10, 9, 8]) == [10, 9, 10, 10, 9], "4th example"
Advertisement
Add Comment
Please, Sign In to add comment