मराठी

Write a function in Python to read a text file, Alpha.txt and displays those lines which begin with the word ‘You’.

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
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2023-2024 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×