Python program to Read Data from File into Lines and Characters

x = [i.strip() for i in
open("C:/Users/USER/Desktop/Python.txt")]
print(x)

 

 

 

Output:

['Hello World 1', 'Hello World 2', 'Hello World 3', 'Hello World 4', 'Hello World 5', 'Hello World 6']

 

Subscribe For Daily Updates