Skip to content

Instantly share code, notes, and snippets.

@joetechem
Last active February 26, 2017 16:29
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 joetechem/69e1eb5c3029e5c0dffaedecb6e09977 to your computer and use it in GitHub Desktop.
Save joetechem/69e1eb5c3029e5c0dffaedecb6e09977 to your computer and use it in GitHub Desktop.
actively taking user input to store in a dictionary
# Python 2.7
# In this example, the user's will be asked for their name and a stream or river they visited
# setting up empty dictionary
responses = {}
# Set a flag to indicate that polling is active.
polling_active = True
while polling_active:
# Prompt for the person's name and response.
name = raw_input("\nWhat is your name? ")
response = raw_input("Which VA stream did you take measurements? ")
# storing the responses.
responses[name] = response
# Find out if there is another team member that needs to input data
repeat = raw_input("Is there another person on your team that needs to respond? (yes/no) ")
if repeat == "no":
polling_active = False
# Polling is complete. Now, Show the results.
print("\n--- Stream Visitation Results ---")
for name, response in responses.items():
print(name + " took measurements at " + response + ".")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment