Skip to content

Instantly share code, notes, and snippets.

@neptunius
Created September 11, 2019 22:06
Show Gist options
  • Save neptunius/cfc3b6af7566ce56debe87ace63e0502 to your computer and use it in GitHub Desktop.
Save neptunius/cfc3b6af7566ce56debe87ace63e0502 to your computer and use it in GitHub Desktop.
Code snippets to show how to reduce line length and complexity
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