Advertisement
SimeonTs

SUPyF Lists - Extra 01. Distinct List

Jun 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. """
  2. Lists
  3. Check your answer: https://judge.softuni.bg/Contests/Practice/Index/425#0
  4.  
  5. 01. Distinct List
  6.  
  7. Problem:
  8. You will be given a list of integers on the first line of the input (space-separated).
  9. Remove all repeating elements from the list.
  10.  
  11. Examples:
  12. Input                   Output                  Comments
  13. 1 2 3 4                 1 2 3 4                 No repeating elements
  14. 7 8 9 7 2 3 4 1 2       7 8 9 2 3 4 1           7 and 2 are already present in the list >>> remove them
  15. 20 8 12 13 4 4 8 5      20 8 12 13 4 5          4 and 8 are already present in the list >>> remove them
  16. """
  17.  
  18. nums = [int(item) for item in input().split(" ")]
  19.  
  20. for num in nums:
  21.     while nums.count(num) != 1:
  22.         nums.reverse()
  23.         nums.remove(num)
  24.         nums.reverse()
  25.  
  26. for num in nums:
  27.     print(num, end=" ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement