Input from a file
Input from a file
%cat /tmp/test.txtOutput:
1 2 3 4 5
6 7 8 9 10with open('/tmp/test.txt','r') as fp:
    while True:
        line=fp.readline()
        if line:
            line=line.strip('\n')
            print(line.split(' '))
        else:
            breakOutput:
['1', '2', '3', '4', '5']
['6', '7', '8', '9', '10']Last updated
Was this helpful?