Advertisements
Advertisements
प्रश्न
Write a function in Python to read a text file, Alpha.txt and displays those lines which begin with the word ‘You’.
टिप्पणी लिखिए
Advertisements
उत्तर
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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
