Почему мой для l oop распечатывает список дважды - PullRequest
0 голосов
/ 18 января 2020

Так что это может быть действительно глупый вопрос, но я новичок в python. Но почему моя печатная книга l oop

def Read_and_Slice(filename = "INSR.txt"):
inf = open(filename)
data = inf.readlines()
inf.close()
newlines = []

for I in data[4::2]:
    line1= I.strip().replace(" ", "")
    newlines.append(line1)

print(newlines)

line = ""

for j in range(len(newlines)-1):
    line = newlines[j]+ newlines[j+1] + line

return line
...