I have a text file which contains two lines of text. Each line contains student names separated by a comma.
I'm trying to write a program which will read each line and convert it to a list. My solution seems to make two lists but I don't know how to differentiate between the two as both lists are called "filelist". For example I may need to append to the second list. How would I differentiate between the two?
Or is it possible for it to create completely separate lists with different names? I want the program to be able to handle many lines in the text file ideally.
My code is:
filelist=[]
with open("students.txt") as students:
for line in students:
filelist.append(line.strip().split(","))
print(filelist)