Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions

Question

Question 14 (3 points) Compare and contrast bailor and bailee.

Answered: 1 week ago