Question: Problem 1 Create a function called unique that determines the unique values in a list and returns these values in their own list. For example,
Problem 1 Create a function called unique that determines the unique values in a list and returns these values in their own list. For example, if your input list is [1,1,2,3], your function should return [1,2,3]. HINT: Iterate over the input list one element at a time. Start populating a new list which you will eventually return. Call it output_list. Before you add a new element into this list (you can use the append method to add elements), make sure that your element of interest is not already present in it. This function should be able to handle values of all Python types.
the following code returns "unexpected EOF while parsing"
def unique(input_list):
output_list = []
for x in input_list:
if x not in output_list:
output_list.append(x)
return output_list
if __name__ == '__main__':
# do not write anything here (the instructor will use this space to test
# your function)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
