Remove repeated python numbers

Asked

Viewed 15 times

0

I’m not getting my program to print this output

That’s the way out should be list = [2, 4, 2, 2, 3, 3, 1] remove_repeated(list) [1, 2, 3, 4]

My programming for the problem is wrong, someone can help me.

list = input("Enter a list with integers: ")

print("You typed the following numbers: ") print(list)

def remove_repeated(l):

lista = l
i = 0
while i < len(lista):
    j = i + 1
    while j < len(lista):
        if lista[j] == lista[i]:
            del(lista[j])
        else:
            j = j + 1
    i = i + 1

return sorted(lista)

print("Your filtered and ordered list: ") print(list)

Citation

  • list = input("Type a list with integers: ") print("You typed the following numbers: ") print(list) def remove_repeaters(l): list = l i = 0 i < Len(list): j = i + 1 whilej < Len(list): if list[j] == list[i]: del(list[j]) Else: j = j + 1 i = i + 1 Return Sorted(list) print("Your filtered and sorted list: ")&#Xa print(list)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.