Welcome to Westonci.ca, where your questions are met with accurate answers from a community of experts and enthusiasts. Connect with professionals ready to provide precise answers to your questions on our comprehensive Q&A platform. Discover in-depth answers to your questions from a wide network of professionals on our user-friendly Q&A platform.
Sagot :
Answer:
Explanation:
The following code is written in Python, it is a function that takes in the file location and two words as arguments. Then it reads the file and loops through to see if those two words are found in succession and how many times. Finally it returns the number of times those words are found in succession within the file.
def countSuccession(file, word1, word2):
file = open(file, "r")
words = file.read()
words = words.replace('.', '')
words = words.split(' ')
count = 0
for index in range(len(words)):
if words.__getitem__(index) == word1 and words.__getitem__(index + 1) == word2:
count += 1
return count

We appreciate your visit. Hopefully, the answers you found were beneficial. Don't hesitate to come back for more information. Thanks for using our platform. We aim to provide accurate and up-to-date answers to all your queries. Come back soon. Get the answers you need at Westonci.ca. Stay informed with our latest expert advice.