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
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