Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. # Get university colors from the user and return as a dict
  2. def get_colors():
  3. color_dict = {}
  4.  
  5. univ_name = input("Enter a university name (or enter to stop): ")
  6. while univ_name != '':
  7. univ_color = input("Enter the color: ")
  8. color_dict[univ_name] = univ_color
  9.  
  10. # Get the next university name...
  11. univ_name = input("Enter a university name (or enter to stop): ")
  12.  
  13. return color_dict
  14.  
  15.  
  16. # Print the university colors
  17. def print_colors(univ_colors):
  18. # Loop over all keys, printing out each value.
  19. for univ in univ_colors:
  20. print("The color for", univ, "is", univ_colors[univ])
  21.  
  22.  
  23. # Main function
  24. def main():
  25. color_dict = get_colors()
  26. print_colors(color_dict)
  27.  
  28.  
  29. # Run the program
  30. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement