aneliabogeva

Travel company

Jul 8th, 2019
105
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cities = {}
  2.  
  3. while True:
  4. command = input()
  5. if command == "ready":
  6. break
  7. a = [item for item in command.split(":")]
  8. city = a[0]
  9.  
  10. b = [item for item in a[1].split(",")]
  11.  
  12. for i in b:
  13. c = [item for item in i.split("-")]
  14. if city not in cities:
  15. cities[city] = {}
  16. cities[city][c[0]] = int(c[1])
  17. for city, transport in cities.items():
  18. cities[city] = sum(transport.values())
  19.  
  20. while True:
  21. command = input()
  22. if command == "travel time!":
  23. break
  24. a = [item for item in command.split(" ")]
  25. check_city = a[0]
  26. value = int(a[1])
  27. if check_city in cities:
  28. if value <= cities[check_city]:
  29. print(f"{check_city} -> all {value} accommodated")
  30. else:
  31. print(f"{check_city} -> all except {abs(cities[check_city] - value)} accommodated")
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×