Computer Science

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

Python

Python List Manipulation

1 Like

Answer

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]

Answered By

1 Like


Related Questions