Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """ This is a program that removes the duplicates of elements in a given list of
- numbers supplied by the user. Please note that the number of the elements supplied
- should be greater than 15, otherwise, you dont get to proceed """
- type_numbers = input("Enter your list of numbers and use a comma and whitespace\
- as a separator between two numbers: ")
- list_of_numbers = type_numbers.split(", ") # The splits the numbers to a list
- def remove_duplicates(numbers):
- mylist = list(dict.fromkeys(numbers))
- if len(numbers) <= 15: # Checking if the numbers are upto 15
- print("Error!: The number of the elements is not upto 15, it is", len(numbers))
- else:
- print("The length of the original list is: ", len(list_of_numbers))
- print("The length of the final list is: ", len(mylist))
- mylist.sort()
- print("my unique and sorted list is", mylist)
- remove_duplicates(list_of_numbers)
- # Enter your list of numbers and use a comma and whitespaceas a separator between two numbers: 1, 2, 3,
- # 4, 3, 2
- # Error!: The number of the elements is not upto 15,
- # it is 6
- # Enter your list of numbers and use a comma and whitespaceas a separator between two numbers: 1, 2, 4,
- # 5, 5, 4, 3, 2, 4, 4, 5, 6, 3, 2, 5, 4, 3, 3, 2
- # The length of the original list is: 19
- # The length of the final list is: 6
- # my unique list is ['1', '2', '3', '4', '5', '6']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement