CBSE Class 12 Computer Science Question 89 of 120

Review of Python Basics — Question 41

Back to all questions
41
Question

Question 36

Write a Python program to get unique values from a list.

Solution
input_list = eval(input("Enter the list: "))
unique_values = []

for item in input_list:
    if item not in unique_values:
        unique_values.append(item)

print("Unique values from the list:", unique_values)
Output
Enter the list: [1, 2, 3, 3, 4, 5, 5, 6, 6, 7]
Unique values from the list: [1, 2, 3, 4, 5, 6, 7]
Answer