Reading specific columns from a text file in python

f=open(file,”r”) lines=f.readlines() result=[] for x in lines: result.append(x.split(‘ ‘)[1]) f.close() You can do the same using a list comprehension print([x.split(‘ ‘)[1] for x in open(file).readlines()]) Docs on split() string.split(s[, sep[, maxsplit]]) Return a list of the words of the string s. If the optional second argument sep is absent or None, the words are separated … Read more