Geocrack

roomate

Jun 29th, 2022 (edited)
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.63 KB | None | 0 0
  1. roommate_dict = {
  2.     'Alice': {'age': 25, 'city': 'New York'},
  3.     'Bob': {'age': 27, 'city': 'Paris'},
  4.     'Charlie': {'age': 29, 'city': 'London'},
  5.     'Dan': {'age': 31, 'city': 'Berlin'},
  6.     'Ed': {'age': 33, 'city': 'Madrid'},
  7.     'Frank': {'age': 35, 'city': 'Barcelona'},
  8.     'George': {'age': 37, 'city': 'Rome'},
  9.     'Harry': {'age': 39, 'city': 'Amsterdam'},
  10.     'Ivan': {'age': 41, 'city': 'Stockholm'},
  11.     'John': {'age': 43, 'city': 'Vienna'},
  12.     'Kevin': {'age': 45, 'city': 'Zurich'},
  13.     'Linda': {'age': 47, 'city': 'Hamburg'},
  14.     'Mark': {'age': 49, 'city': 'Munich'},
  15.     'Nancy': {'age': 51, 'city': 'Frankfurt'},
  16.     'Olivia': {'age': 53, 'city': 'Bremen'},
  17.     'Peter': {'age': 55, 'city': 'Dortmund'},
  18.     'Quinn': {'age': 57, 'city': 'Leipzig'},
  19.     'Robert': {'age': 59, 'city': 'Cologne'},
  20.     'Sandra': {'age': 61, 'city': 'Dresden'},  
  21.     'Tim': {'age': 63, 'city': 'Hannover'},
  22.     'Ulf': {'age': 65, 'city': 'Bergen'},
  23.     'Victor': {'age': 67, 'city': 'Aachen'},
  24.     'Wendy': {'age': 69, 'city': 'Frankfurt'},
  25.     'Xavier': {'age': 71, 'city': 'Stuttgart'},
  26.     'Yvonne': {'age': 73, 'city': 'Hannover'},
  27.     'Zoe': {'age': 75, 'city': 'Munich'}
  28. }
  29.  
  30.  
  31. cost = 25
  32.    
  33. for each_roommate in (roommate_dict.keys()):
  34.     roommate_name = set(list(roommate_dict.keys()))
  35.     user_input = input(f'will ({each_roommate}) pay "full" or "half" this month?').casefold()
  36.     if user_input == "half":
  37.         roommate_dict[each_roommate]["cost"] =  cost/2
  38.     elif user_input == "full":
  39.         roommate_dict[each_roommate] ["cost"] = cost
  40.     else:
  41.         print("Please enter 'half' or 'full'")
  42.        
  43.  
Add Comment
Please, Sign In to add comment