Reputation: 740
This code has 2 functions one for taking a list from user and the other one should remove the duplications in this list , it can be done without using functions but im learning functions in Python.
How can I take the list that the user has entered in function take_list()
and pass it to the function no_duplication()
?
when I do it i get this error
Unresolved reference 'k'
at the line : no_duplication(k)
def take_list():
k = []
i = 0
list_length = int(input("how many elements your list has ? \n "))
while i < list_length:
element = int(input("enter you list elements : "))
k.append(element)
i += 1
print(k, " is your list")
return k
def no_duplication(k):
k = set(k)
k = list(k)
print(k, " Your list without duplications")
take_list()
no_duplication(k)
Upvotes: 0
Views: 220
Reputation: 2214
You need to assign returned value to a new variable and pass that to no_duplication
as parameter:
k = take_list()
no_duplication(k)
Upvotes: 1