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
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