Created
September 11, 2019 22:06
-
-
Save neptunius/cfc3b6af7566ce56debe87ace63e0502 to your computer and use it in GitHub Desktop.
Code snippets to show how to reduce line length and complexity
This file contains 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
madlib = (madlib.replace(word_type, input("Enter a {}: ".format(word_type)), 1)) | |
prompt = "Enter a {}: ".format(word_type) | |
user_word = input(prompt) | |
madlib = madlib.replace(word_type, user_word, 1) | |
################################################################################ | |
for x in range(len(stories[story]["words"])): | |
stories[story]["words"][x] = input(stories[story]["words"][x] + ": ") | |
word_types = stories[story]["words"] | |
for index in range(len(word_types)): | |
prompt = "Enter a " + word_types[index] + ": " | |
user_word = input(prompt) | |
word_types[index] = user_word |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment