1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
castortr0y [4]
3 years ago
5

The function below takes a string argument sentence. Complete the function to return the second word of the sentence. You can as

sume that the words of the sentence are separated by whitespace. If the sentence contains less than two words, return None. If the last character of the word you are returning is a comma, semi-colon, period, exclamation point, or question mark, remove that last character.
Computers and Technology
1 answer:
enyata [817]3 years ago
3 0

Answer:

Following are the code to this question:

def string_argument(val): #Defining a method string_argument

   w= val.split() #Define variable that split value

   if len(w) < 2: # Define condition to check value length  

       return None #return value

   if w[1][-1] in ",;.!?": #Define condition to check special character  

       return w[1][:-1] #return second word

       return w[1] # return value

print(string_argument("good morning hello?")) #call method and print return value

print(string_argument("hii morning, DEV"))#call method and print return value

print(string_argument("how are you? MR"))#call method and print return value

print(string_argument("dev lambda. Who"))#call method and print return value

print(string_argument("thanks")) #call method and print return value

Output:

None

morning

None

lambda

None

Explanation:

In the given python program, a method "string_argument" is declared, that accepts a value val in its parameter, inside the method, another variable "w" is used, that splits the argument value. In the next line, two if conditional block is used which can be described as follows:

  • In the first block, it will check the length, it is not less then 2, if this condition is true it will return none.
  • In the second if the block it will check, that variable val holds any special character in its second word so, it will return the second word.
You might be interested in
Well this isn't school related, but how do i watch dubbed and subbed anime for free on my computer?
Shtirlitz [24]
Crunchyroll or my anime list. Both of these work.

Hope this helps you

3 0
4 years ago
Read 2 more answers
Clicking on the cube that appears in the top right of the 3D view window will: (1 point)
german

Answer:

The correct option is;

Toggle between orthographic and perspective views

Explanation:

On a game design program such as Unity 3D, when the cube with colored pointers that can be located on the 3D view window is clicked, it will bring about a switch between the perspective or 90 degrees and orthogonal views which enables the display of the object in three dimension that appears more like real life figures.

5 0
3 years ago
Please answer no files !!
Pachacha [2.7K]

Answer:

im not exactly sure but i think its c

Explanation:

8 0
3 years ago
What are the importance of switches in our electron device
svp [43]

This way we can turn it on or off so we don't waste power.

Hope I helped! Just tell me if i'm wrong!

3 0
3 years ago
Is October tornado season?
Reptile [31]
No October is not tornado season
5 0
3 years ago
Read 2 more answers
Other questions:
  • Jason wants to open a program with the command prompt window. Which command should he type in the Run dialog box to open the com
    10·1 answer
  • If you have a database with birthdates, and you would like to find everyone who was born before June 16, 1967, what would you en
    15·2 answers
  • A paradigm innovation occurs when:
    6·1 answer
  • What is a functional simulation?
    14·1 answer
  • Which information is considered free for use?
    9·2 answers
  • When performing a basic search with Bing, you first type in your search expression and then click a button to begin the search;
    13·1 answer
  • What is the role of the federal government in regulating the media and the internet?
    6·2 answers
  • Sales representatives want to capture custom feedback record details related to each Account. The sales reps want to accomplish
    12·1 answer
  • Rate my dog out of ten give explanation why
    12·1 answer
  • Choose the words that make the following sentence true.<br> Primary memory is
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!