menu
bartleby
search
close search
Hit Return to see all results

I don't want the answer, but can you please help me understand what they are asking?  I am having difficulty understanding the question. Thank you!This is for an Intro to Python class:Assume that sentence is a variable that has been associated with a string consisting of words separated by single space characters with a period at the end. For example: "This is a possible value of sentence."Write the statements needed so that the variable secondWord is associated with the second word of the value of sentence . So, if the value of sentence were "Broccoli is delicious." your code would associate secondWord with the value "is" .

Question

I don't want the answer, but can you please help me understand what they are asking?  I am having difficulty understanding the question. Thank you!

This is for an Intro to Python class:

Assume that sentence is a variable that has been associated with a string consisting of words separated by single space characters with a period at the end. For example: "This is a possible value of sentence."

Write the statements needed so that the variable secondWord is associated with the second word of the value of sentence . So, if the value of sentence were "Broccoli is delicious." your code would associate secondWord with the value "is" .

check_circleAnswer
Step 1

Program code:

...
sentence='Broccoli is delicious.
#find the first space index
start-sentence.find (' ')
#find the second space index
end-sentence.find(' ',start+1)
#extract the second word that exists between start and end
secondword=sentence [ start+1:end]
#print the second word
print(secondWord)
help_outline

Image Transcriptionclose

sentence='Broccoli is delicious. #find the first space index start-sentence.find (' ') #find the second space index end-sentence.find(' ',start+1) #extract the second word that exists between start and end secondword=sentence [ start+1:end] #print the second word print(secondWord)

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Our solutions are written by experts, many with advanced degrees, and available 24/7

See Solution
Tagged in

Engineering

Computer Science

Python

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: how can I write a statement in C++ that would print last name, followed by a comma, followed by firs...

A: Given below is the C++ program to print a statement with last name, followed by comma, followed by f...

question_answer

Q: write a program in c++. You work for a box company, and have been asked to write a program to compar...

A: Solution:The C++ program has the following algorithm:Declare and initialize the required variables.D...

question_answer

Q: Question: Write a function to display a pattern as follows: 1 2       1 ... ... n       n-1         ...

A: Solution:The python program has the following algorithm:In the displayPattern() function,Declare and...

question_answer

Q: Use the class, WhatPrints, to view what prints for each of the method calls below:doSomething(5);doS...

A: Explanation:In the given program, there are four methods which has the same method name with differe...

question_answer

Q: 2. Write a program called ListOddNumbers that prints the below (there is a single space between each...

A: Solution: 2. The below program is written in Java language to display the odd number between 1 and 5...

question_answer

Q: As an IT manager, what strategy would you have followed to avoid the failed implementation of ERP sy...

A: ERP system:It denotes software for business process management that permits an organization in using...

question_answer

Q: Convert the grammar S → aSb|bSa|a|b|ab into Greibach normal form.

A: A context free grammar  is in Greibach Normal Form (GNF) if all production rules satisfy one of the ...

question_answer

Q: This is C++ my programming lab 11.7: Customer AccountsWrite a program that uses a structure to store...

A: Declare the structure Customer_Accounts with the required data fields. Also, declare an array of 20 ...

question_answer

Q: Write a program in Eclipse that prompts the user for first name, last name, then secret number. The ...

A: Program plan:Include the required header file.Define the class “Main”.Define the “defaultInfo” metho...

Sorry about that. What wasn’t helpful?