CBSE Class 11 Computer Science
Question 58 of 82
Lists in Python — Question 23
Back to all questions 23
Question Write a program to read a list of elements. Modify this list so that it does not contain any duplicate elements, i.e., all elements occurring multiple times in the list should appear only once.
nums = eval(input("Enter list: "))
unique_nums = []
for num in nums:
if num not in unique_nums:
unique_nums.append(num)
print("The list without duplicates is: ", unique_nums)Enter list: [11, 34, 67, 8, 66, 11, 8, 5]
The list without duplicates is: [11, 34, 67, 8, 66, 5]