Skip to content

Instantly share code, notes, and snippets.

@rdempsey
Last active December 20, 2017 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdempsey/1d6e4148d1d7e8dbb5ae7e145aef22a3 to your computer and use it in GitHub Desktop.
Save rdempsey/1d6e4148d1d7e8dbb5ae7e145aef22a3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# Create the lists of things to choose from
verbs = ['eat', 'speak', 'kick', 'punch', 'yell']
fruit = ['apples', 'oranges', 'pears', 'grapes', 'bananas', 'mangos']
time_of_day = ['morning', 'afternoon', 'evening', 'dusk', 'dawn']
# Run this code until the user hits `Control-C` on her keyboard.
while True:
# Ask the user for various inputs
user_verb = input("\nPick a number between 0 and 4: ")
user_fruit = input("Now pick a number between 0 and 5: ")
user_time_of_day = input("Now pick another number between 0 and 4" \
" but different than your first: ")
user_fav_activity = input("What is your favorite activity?: ")
# Convert the inputs to integers
user_verb = int(user_verb)
user_fruit = int(user_fruit)
user_time_of_day = int(user_time_of_day)
# If the user entered the same number for time of day and verb, yell at him and exit
if user_time_of_day == user_verb:
print("Hey! I told you to pick a different number between 0 and 4!")
print("I'm done. Goodbye.")
break
# Assuming everything worked, print out the inane sentence.
# Use the integer values the user input to select the element in the lists
# Oh yeah, the position of the first element in a Python list is 0, not 1
print("Oh yeah! I love to {} {} in the {} while I'm {}! \n" \
.format(verbs[user_verb],
fruit[user_fruit],
time_of_day[user_time_of_day],
user_fav_activity))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment