1
I have a TXT file with numbers separated by spaces and I want to sequence from the smallest number to the largest, just the numbers from the first line of that file. The logic of sequencing I believe I’ve succeeded:
tam_entrada = len(lista)
for i in range (tam_entrada):
for j in range (1, tam_entrada-i):
if lista[j] < lista[j-1]:
lista[j], lista[j-1] = lista[j-1], lista[j]
print(lista)
But I can’t import the first line of the file as a vector I named lista
. Can someone help me, please?
Insert in your question the part of the file in question and also the part of the code that reads this file and turns into list.
– Rogério Dec
fnands to import the first line of the file just insert: with open(r'FILE PATH') as f: first_line = f.readline()
– Clayton Tosatti