Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Get university colors from the user and return as a dict
- def get_colors():
- color_dict = {}
- univ_name = input("Enter a university name (or enter to stop): ")
- while univ_name != '':
- univ_color = input("Enter the color: ")
- color_dict[univ_name] = univ_color
- # Get the next university name...
- univ_name = input("Enter a university name (or enter to stop): ")
- return color_dict
- # Print the university colors
- def print_colors(univ_colors):
- # Loop over all keys, printing out each value.
- for univ in univ_colors:
- print("The color for", univ, "is", univ_colors[univ])
- # Main function
- def main():
- color_dict = get_colors()
- print_colors(color_dict)
- # Run the program
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement