Created
April 5, 2018 03:13
-
-
Save calthoff/32c0aa26435fcef90dcf369ab16cc898 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| text = """Giraffes have aroused | |
| the curiosity of __PLURAL_NOUN__ | |
| since earliest times. The | |
| giraffe is the tallest of all | |
| living __PLURAL_NOUN__, but | |
| scientists are unable to | |
| explain how it got its long | |
| __PART_OF_THE_BODY__. The | |
| giraffe's tremendous height, | |
| which might reach __NUMBER__ | |
| __PLURAL_NOUN__, comes from | |
| it legs and __BODYPART__. | |
| """ | |
| def mad_libs(mls): | |
| hints = re.findall("__.*?__", mls) | |
| if hints is not None: | |
| for word in hints: | |
| q = "Enter a {}".format(word) | |
| new = input(q) | |
| mls = mls.replace(word, new, 1) | |
| print('\n') | |
| mls = mls.replace("\n", "") | |
| print(mls) | |
| else: | |
| print("invalid mls") | |
| mad_libs(text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment