Last active
February 26, 2017 16:29
-
-
Save joetechem/69e1eb5c3029e5c0dffaedecb6e09977 to your computer and use it in GitHub Desktop.
actively taking user input to store in a dictionary
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
# 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