Question: Python code Have 'KJV.txt' loaded in the same folder with this jupyter notebook file. Then write a function that: Takes two words Print all lines

Python code

Have 'KJV.txt' loaded in the same folder with this jupyter notebook file. Then write a function that:

  • Takes two words
  • Print all lines that contains both words, in a case-insensitive way
  • At the end, print the number of lines

And test the function with the following:

  • 'good' and 'evil': 71 lines
  • 'god' and 'love': 69 lines
  • Your choice! Try any two words (not so simple ones)

my attempt

input

def wordCount(str1, str2): count = 0 for line in "KJV.txt": containsStr1 = False containsStr2 = False for word in line: if(word == str1): containsStr1 = True if(word == str2): containsStr2 = True if(containsStr1 == True and containsStr2 == True): count += 1 return count

print(wordCount("good", "evil"))

output

0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!