Answered step by step
Verified Expert Solution
Question
1 Approved Answer
THIS IS PYTHON THIS ANSWER IS WRONG def unique_list(l): a_set = set(l) number_of_unique_values = len(a_set) print(number_of_unique_values) x = [] for a in l: if a
THIS IS PYTHON
THIS ANSWER IS WRONG
def unique_list(l): a_set = set(l) number_of_unique_values = len(a_set) print(number_of_unique_values) x = [] for a in l: if a not in x: x.append(a) return x print(unique_list([1,2,3,3,3,3,4,5]))
2. Write a function get_unique( ) that takes a list of numbers and returns the number of unique values and a list containing all unique values. Example: list1 =[3,1,4,1,5,9,5,4] n_unique, list_unique = get_unique(list1) print(n_unique) print(list_unique) Output: 5 [1,3,4,5,9] (The order does not matter)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started