Question: Use a for loop with a break statement and the append method to write a function wordlist(text) that takes a single argument textin the form
Use a for loop with a break statement and the append method to write a function wordlist(text) that takes a single argument textin the form of a string, and returns a list of the all-alphabetic words in text up until the first word containing a non-alphabetic character (and no words beyond that point). Note that text should be separated into words based on spaces. For example:
>>> wordlist("How much wood could a k9 chuck") ['How', 'much', 'wood', 'could', 'a']
>>> wordlist("As much wood as a woodchuck could chuck!") ['As', 'much', 'wood', 'as', 'a', 'woodchuck', 'could']
>>> wordlist("99 Luftballons") []
Hint
A string method that you may find useful is isalpha, that returns True if the string it is applied to is made up of all-alphabetic characters, and False otherwise, e.g.:
print("Hello world".isalpha()) print("I <3 Python".isalpha()) print("Cooool".isalpha()) Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
