I'm new to python and was hoping for some assistance please.
I have a small script that reads a text file and prints only the fist column using a for loop:
list = open("/etc/jbstorelist")
for column in list:
print(column.split()[0])
But I would like to take all the lines printed in the for loop and create one single variable for it.
In other words, the text file /etc/jbstorelist has 3 columns and basically I want a list with only the first column, in the form of a single variable.
Any guidance would be appreciated. Thank you.
lst = []and then replaceprint(column.split()[0])with:lst.append(column.split()[0])