Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(IN PYTHON) Problem 1 Write a function word_count() that performs the following actions: Opens a file called novel.txt. You can assume that the file exists
(IN PYTHON) Problem 1
Write a function word_count() that performs the following actions:
Opens a file called novel.txt.
You can assume that the file exists and is located in the same directory as your code file.
Reads in the contents of the file, and stores it in a variable called text.
Uses the split() function to obtain a list containing all of the individual words in text.
For this question, assume that all words will be separated by spaces.
Returns the number of words in the list.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started