Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Due: May 04, 2018 11 : 59 pm submit Instructions from your teacher: Problem Comp

ID: 3719947 • Letter: D

Question

Due: May 04, 2018 11 : 59 pm

submit

Instructions from your teacher:

Problem

Complete the function reverseStringWords() to take in a string and reverse the order of the words in the string. In other words, you shouldn't reverse the string letter by letter, but word by word.

You may not use Python's built-ins like reversed() or slice the string backwards.

It's ok to use the split() function.

Example

reverseStringWords("Murt likes Jim") # returns "Jim likes Murt"

def reverseStringWords(string):?

1 def reverseStringWords(string): Problem Complete the function reversestringWords() to take in a string and reverse the order of the words in the string. In other words, you shouldn't reverse the string letter by letter, but word by word. You may not use Python's built-ins like reversed() or slice the string backwards It's ok to use the split() function. Example reversestringWords (''Hurt likes Jim") # returns "Jim Ii kes Murt"

Explanation / Answer

def reverseStringWords(string): words = string.split() result = '' i = len(words) - 1 while i >= 0: result += words[i] if i != 0: result += ' ' i -= 1 return result

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote