Advertisements
Advertisements
प्रश्न
Write a Python function that displays the number of times the word “Python” appears in a text file named “Prog.txt”.
कोड लेखन
Advertisements
उत्तर
def count_python():
count = 0
with open("Prog.txt", 'r') as file:
text = file.read()
words = text.split()
for word in words:
if word.lower() == "python":
count += 1
print("The word Python appears", count, "times.")shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
