Write a function that takes a sentence as input and returns it scrambled (the order of the words mixed up in some way). For example, if it is passed “Does anything rhyme with orange?” it might return “Orange with does anything rhyme?”.
Note: With the example the question gives, its implied that the answer needs to include capitalizing the first letter of the first word, lower-caseing the original first word, and ensuring that the punctuation mark at the end stays consistent.
```
import random
def scramble(source):
mark = source[-1]
source = source[0:len(source)-1-1]
parts = source.split(" ")
newString = ""
while len(parts)>0:
p = random.choice(parts)
parts.remove(p)
newString = newString+p.lower()+" "
lastIndex = len(newString)-1
newString = newString[0:lastIndex] +mark
newString= newString[0].upper() + newString[1:]
return newString
```
You might also like to view...
_____ space refers to nonprintable characters such as spaces (created by pressing the spacebar), new line characters (created by pressing the Enter key), or tab characters (created by pressing the Tab key).
A. Blank B. White C. Empty D. Character
Pam, your new marketing manager, is exploring the purchase of tens of thousands of email addresses, from a legitimate source, for the purpose of sending product information to the masses. She has asked your opinion. Would you agree or disagree with her idea? Why or why not?
What will be an ideal response?
The date serial number for December 25, 2007 is 12252007
Indicate whether the statement is true or false
The ________ button, found on the Quick Access Toolbar, reverses the last action or series of actions
A) Undo B) Restore C) Reverse D) Back up