Assignment question :Week5_Exercise1_Q3

Hi, I am facing an error while solving this question.I went through the solution as well.But even the solution is nnot implementable.

Q3
Write a function which takes list of random integers as an input and returns the list all the unique values present in that list. For ex:

Input: [1, 2, 4, 4, 3, 2, 1, 1, 2, 4, 5, 3]
Output : [1, 2, 3, 4, 5]

Sol:def unique_vals(value):
return list(set(x))

x = [1, 2, 4, 4, 3, 2, 1, 1, 2, 4, 5, 3]
unique_vals(x)

Error:
TypeError Traceback (most recent call last)

in () 1 x = [1, 2, 4, 4, 3, 2, 1, 1, 2, 4, 5, 3] ----> 2 unique_vals(x)

in unique_vals(value) 1 def unique_vals(value): ----> 2 return list(set(x))

TypeError: ‘list’ object is not callable

1 Like

It should be

return list(set(value)) 

because in the function definition “value” takes the values of “x”(variable).
Try changing it

No Still not working.I tried to run the solution as well but throwing same error

It is working fine on google colab.

It should be value instead of x in your code