Advertisements
Advertisements
Question
Write a function in Python to read a text file, Alpha.txt and displays those lines which begin with the word ‘You’.
Short/Brief Note
Advertisements
Solution
def test():
fObj1 = open("Alpha.txt","r")
data = fObj1.readlines()
for line in data:
L=line.split()
if L[0]=="You":
print (line)
fObj1.close()shaalaa.com
Reading from a Text File in Python
Is there an error in this question or solution?
