Question: This assignment will use methods and functions to show how Python can locate and extract sub-strings from a string. Use the phrase The quick brown
This assignment will use methods and functions to show how Python can locate and extract sub-strings from a string. Use the phrase "The quick brown fox jumps over the lazy dog" and find the following: The first character position of the strings: "fox", "lazy" and "dog" use the .find method with the spaces to find your place in the word. e.g. position1 = phrase.find(" ") will return 3, because the first space in the string is in position 3 of the string. Display the strings and the starting positions. e.g. print ("In", phrase, "the word fox begins in position", position1) Find the following words by assigning the slice to a variable: "fox", "jumps" and "quick" e.g word1 = phrase[0:3] will assign "the" to the variable word1. Display the length of each string. print the string "I have found the words," ,and concatenate the words with the proper punctuation (e.g. word1+"," etc...)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
