how to form a list from a file in python

Solutions on MaxInterview for how to form a list from a file in python by the best coders in the world

showing results for - "how to form a list from a file in python"
Rashan
10 Jun 2017
1l = []
2for line in in_file:
3    l.append(line.rstrip().split(','))
4
David
22 May 2017
1for line in a_file:
Adalyn
09 Sep 2017
1my_list = [line.split(',') for line in open("filename.txt")]
2
Silvia
27 Apr 2020
1myFile= open( "SomeFile.txt", "r" )
2for x in myFile:
3    print x
4myFile.close()
5
Mahe
22 Mar 2019
1a_file = open("sample.txt", "r")
Olivia
12 Jan 2017
1   i=0
2   List=[""]
3   for Line in inFile:
4      List[i]=Line.split(",")
5      i+=1
6   print List
7
Joshua
08 Jan 2017
1l = []
2for line in in_file:
3    l.append(line.split(','))
4
Abigail
25 Mar 2019
1list_of_lists = []
Ilaria
24 Feb 2018
1List = open("filename.txt").readlines()
2