1
"Make a program that, when filling a list with 8 integers, already stores them increasingly. Show the resulting list each time a value is stored"
lista = []
for x in range(8):
n = int(input("Digite um número inteiro: "))
inseriu = False
for i in range(len(lista)):
if n<lista[i]:
lista.insert(i, n)
inseriu = True
break
if not inseriu:
lista.append(n)
print(lista)
Where did you get the code? If you didn’t understand it, I assume you didn’t develop it.
– Woss
apparently, this variable inserted, will be True if the element has already been inserted in the list, and False if it is the last one in the list. so if it is the last element, it will be put by usefulness.
– Erick Weil