[Solved] How to print selected elements from file?


Here is one way:

with open("fk.txt") as file:   # Use file to refer to the file object
    data = file.readlines()
column1, column2 = [], []
for line in data:
    try:
        entry1, entry2 = line.split(' ')
        column1.append(int(entry1))
        column2.append(int(entry2))
    except ValueError:
        pass
print column1, column2

2

solved How to print selected elements from file?