0
This is an exercise of a USP course. I will post the statement and the code to make the doubt clear.
Write the remove_repeated function that takes as a parameter a list of integer numbers, checks whether such a list has repeated elements and removes them. The function should return a list corresponding to the first list, without repeating elements. The returned list should be sorted.
My code:
def remove_repetidos(x):
c = 0
x.sort()
while c < len(x)-1:
if x[c] == x[c+1]:
del x[c]
else:
c = c+1
return x
x = input("Digite sua lista:")
lista = remove_repetidos(x)
print (lista)
I know the code isn’t optimized. But the question is, how to adapt the function so that it receives several lists as input?
For example, the user wants to run the code and enter any list and return a list with the repeated numbers removed?
Abs,
is it possible to make this read stop without the numbers being separated by commas? for example 12345
– Leila