-3
I am creating a script for my python course.
The script takes as input a sequence of integer numbers terminated by zero and returns the numbers in ascending order, removing the repeated ones.
The script worked at first compilation, but now that I have divided it into a function it is giving some error with the 'list' that I do not understand:
Typeerror: remove_repeated() Missing 1 required positional argument: 'list'
Follow my script:
def remove_repetidos (lista):
lista2 = set(lista)
lista = list(lista2)
lista.sort()
return lista
x = 1
lista = []
while x > 0:
x = int(input("Digite um número inteiro: "))
lista.append(x)
del lista[-1]
remove_repetidos()
Failed to pass the list as the remove_repeated parameter()
– rodrigorf
I guess I’m having a hard time on that question anyway, how do I do that?
– Leandro Sargi
just do
remove_repetidos(lista)
there on the last line– João Pedro Henrique
did this and gave another error now, remove_repeated() take 0 positional arguments, but 1 was Given
– Leandro Sargi
What mistake? Here when I copied and pasted gave error too. In my case it was only because of the accent in "number". After that, it worked normally as expected. See if suddenly that’s it too.
– João Pedro Henrique
I decided to put list between the function parentheses there at the beginning of the code, and at the end also when calling the function, would that be it? Is there any way to put the parameter only in the function call? Example, if I was working with two lists and want to use the same function to organize them
– Leandro Sargi