Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def forecast(**data):
- locations = {}
- result = []
- for key, value in data.items():
- if key not in locations:
- locations[key] = []
- locations[key].append(value)
- locations = sorted(locations.items(), key=lambda x: (x[0]))
- for location, values in locations:
- result.append(f"{location}:")
- for value in sorted(values):
- result.append(f"-{value}")
- return "\n".join(result)
- print(forecast(
- ("Sofia", "Sunny"),
- ("London", "Cloudy"),
- ("New York", "Sunny")))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement