Hi, I need some help finishing the last part of this Python 1 code. The last few functions are incomplete. Thank you.
The instructions were:
The program has three functions in it.
I want you to complete the count_how_many_words() function, and then call it (multiple times) inside main() to find out how many times Poe used the word “Raven” (or “raven”) and how many times he used “Nevermore” (or “nevermore”) inside the poem “The Raven.”
Example output (with incorrect numbers):
The word "Raven" (or "raven") appears 42 times in Edgar Allen Poe's "The Raven."
The word "Nevermore" (or "nevermore") appears 48 times in Edgar Allen Poe's "The Raven."
Following is the code we have to complete:
# this function takes in a string and a list and counts how many times that
# string shows up in that list
def count_how_many_words(word_list, counting_string):
return None #this is just here so the program still compiles
def main():
count = 0
words = break_into_list_of_words(THE_RAVEN)
# print(words)
if __name__ == "__main__":
main()
# this function takes in a string and a list and counts how many times that
# string shows up in that list
def count_how_many_words(word_list, counting_string):
count = 0
counting_string = counting_string.lower()
for i in range(len(word_list)):
if(word_list[i].lower() ==
counting_string):
count += 1
return count #this is just here so the program still
compiles
def main():
count = 0
#words = break_into_list_of_words(THE_RAVEN)
#sample line splitted by space
words = "The word Raven (or raven ) appears 42 times
in Edgar Allen Poe's 'The Raven .'".strip().split(" ")
#print words
print(words)
count = count_how_many_words(words, "raven")
print("Count of Raven: ",count)
#another sample line for testing
words = "The word Nevermore (or nevermore ) appears 48
times in Edgar Allen Poe's The Raven . ".strip().split(" ")
print(words)
count = count_how_many_words(words,"Nevermore")
print("Count of Nevermore: ",count)
if __name__ == "__main__":
main()

Hi, I need some help finishing the last part of this Python 1 code. The last...
I need help in Python. This is a two step problem So I have the code down, but I am missing some requirements that I am stuck on. Also, I need help verifying the problem is correct.:) 7. Random Number File Writer Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500. The application should let the user specify how many random numbers the file...
In python, PART A: I am trying to get a dictionary with size(4, 5, 6) as keys and an array for key containing a list of values (words from file of respective size) associated with those keys I am reading from a file of strings, where I am only interested with words of length 4, 5, and 6 to compute my program reading the text file line by line: At first, I have an empty dictionary then to that I...
Python 3 coding with AWS/Ide. Objective: The purpose of this lab is for you to become familiar with Python’s built-in text container -- class str-- and lists containing multiple strings. One of the advantages of the str class is that, to the programmer, strings in your code may be treated in a manner that is similar to how numbers are treated. Just like ints, floats, a string object (i.e., variable) may be initialized with a literal value or the contents...
Python program This assignment requires you to write a single large program. I have broken it into two parts below as a suggestion for how to approach writing the code. Please turn in one program file. Sentiment Analysis is a Big Data problem which seeks to determine the general attitude of a writer given some text they have written. For instance, we would like to have a program that could look at the text "The film was a breath of...
Please write the following code as simple as possible in python: You will need to define a function with four arguments. Here is what I used: > def find_matches(file1.txt, output1.txt, strings, value): file1.txt will contain a list of various strings. The program must copy from the first argument, and it should be written in the second argument (the second file, "output1.txt"). The third and fourth arguments will determine which specific strings will be copied over to the second file. For...
Python: Implement a function myIndex() that takes as input a text file and a list of words. Search the file and print the word along with the line numbers that word appears in the text as follows: >>> myIndex('raven.txt', ['raven', 'mortal', 'dying', 'ghost', 'ghastly', 'evil', 'demon']) raven 44, 53, 55, 64, 78, 97, 104, 111, 118, 120 mortal 30 dying 9 ghost 9 ghastly 82 evil 99, 106 demon 122 reven.txt: Once upon a midnight dreary, while I pondered weak...
My Python file will not work below and I am not sure why, please help me debug! ********************************* Instructions for program: You’ll use these functions to put together a program that does the following: Gives the user sentences to type, until they type DONE and then the test is over. Counts the number of seconds from when the user begins to when the test is over. Counts and reports: The total number of words the user typed, and how many...
I need help with my Java code. A user enters a sentence and the program will tell you what words were duplicated and how many times. If the same word is in the sentence twice, but one is capitalized, it will not count it as a duplicate. How can I make the program read the same word as the same word, even if one is capitalized and the other is not? For example, "the" and "The" should be counted as...
I am writing python code. I submitted an assignment but the professor said it was a modularization. Can you help me see what part of the code is modularization? Pseudocode: 1. Decalre MainMethod () function: # A. Parameters: Three numbers # B. Put the three numbers in reverse # 2. Main Program # A. Initialize Varibles # B. Accepts three values from the user # C. Invoke MainMethod () function, passing the three numbers as arguments in reverse # D....
Need some help on this Python Problem called "unique words" the text.txt file can be any .txt file with words in it. Write a program that opens a specified text file and then displays the number of unique words in the text file after stripping all the white spaces, comma, and the punctuation marks and list of all the unique words found in the file. The list should be sorted in alphabetical order. The program should handle the ‘file not...