M.Sc Python Programming Assignment 22

M.Sc Python Programming Assignments

Assignment 22

Question:

Write a Python function that takes a list and returns a new list with unique elements of the first list.

Code:

				
					def unique_elements(lst):
    unique_list = list(set(lst))
    return unique_list

# Example usage
my_list = [1, 2, 3, 2, 4, 5, 1, 3, 6]

result = unique_elements(my_list)

print("Unique elements:")
print(result)

				
			

Output:

				
					Unique elements:
[1, 2, 3, 4, 5, 6]

				
			
Tech Amplifier Final Logo