Bubble Sort in python - Problem inserting values in list

Asked

Viewed 42 times

0

Colleagues, I have a problem inserting values into a list, follow the thought:

lista = []

for i in range(0, 4):
   lista[i] = int(input('Informe um numero: '))

for i in range(0, len(lista)-1):
   for j in range(i + 1, len(lista)):
      if lista[i] > lista[j]:
          aux = lista[i]
          lista[i] = lista[j]
          lista[j] = aux

print(lista)
  • You won’t even explain WHAT PROBLEM you’re having?!

  • The first loop I made was to fill in the error list. I know the logic of the second one is right because I have tested it with a list made.

1 answer

0


Browser other questions tagged

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