Challenge: Calculate String Length
Follow the instructions to solve the challenge.
We'll cover the following
Solve the exercise
We are given a text file. The words in the text file are phonetically similar, with a heavy emphasis on the sh
letters. Our task is to find the lengths of each word that include the sh
sounds.
Please follow the instructions to complete the challenge:
- Read the text file in the given directory below using the
read_file()
command.
"hello.txt"
-
Turn the text into lowercase.
-
Replace all
\n
characters with nothing. -
Create a list by splitting the text by the blanks.
-
Choose the first element of the list.
-
Create a detect object for the words that involve
sh
. -
Mask the detect object with the list object and assign a new variable to the outcome.
-
Calculate the length of each word in the masked object.
-
Name the outcome
result
.
Note: Naming the final output
result
is crucial to completing this challenge successfully.
Get hands-on with 1400+ tech skills courses.