Read lines from a text file India.txt to findand display the occurrence of the word "India"

 #read lines from a text file India.txt to findand display the occurrence of the word "India"

def disp():

    count=0

    f=open("India.txt","r")

    for line in f:

        word=line.split()

        for w in word:

            if w=="India":

                count=count+1

    print("Total occurrence of the word 'India':",count)

disp()



Comments

Popular posts from this blog

Binary file update using Python program