This is an exercise in a USP course. I will post the statement and the code so that the doubt is clear.
Write the remove_repetitions function that receives a list of integers as a parameter, checks to see if it has repeating elements and removes them. The function should return a list corresponding to the first list, without repeated elements. The returned list must 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 is not optimized. But the question is, how to adapt the function so that it receives several lists as input?
For example, does the user want to rotate the code and type any list and return a list with the repeated numbers removed?
Abs,