Transcribed Image Text: LAB RESTRICTIONS, PLEASE READ:
You are not allowed to use any imports, except for the ones given (if any).
You may not use any lists or list methods, for the same reasons as last week.
also do not use try-except statements, you should be able to anticipate
or prevent any errors from happening at all! Transcribed Image Text: Edef reverse_sentence (s: str) -> str:
Given a sentence , we define a word within to be a continuous
sequence of characters in that starts with a capital letter and
ends before the next capital letter in the string or at the end of
the string, whichever comes first. A word can include a mixture of
punctuation and spaces.
This means that in the string ‘ATest string!’, there are in fact only two
words: ‘A’ and ‘Test string!’. Again, keep in mind that words start with a
capital letter and continue until the next capital letter or the end of the
string, which is why we consider ‘Test string!’ as one word.
This function will reverse each word found in the string, and return a new
string with the reversed words, as illustrated in the doctest below.
>>> reverse_sentence(‘ATest string!’)
‘A!gnirts tseT’
return