Skip to content

Commit

Permalink
replaced .get() with operator [] for all places
Browse files Browse the repository at this point in the history
  • Loading branch information
romkapomka12 committed Nov 29, 2023
1 parent 5e73beb commit 315f812
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ def get_weather() -> None:
if res.status_code == 200:
weather_dict = res.json()

location = weather_dict.get("location").get("name")
last_updated = weather_dict.get("current").get("last_updated")
temp_c = weather_dict.get("current").get("temp_c")
humidity = weather_dict.get("current").get("humidity")
condition_text = (weather_dict.get("current")
.get("condition")
.get("text"))
location = weather_dict["location"]["name"]
last_updated = weather_dict["current"]["last_updated"]
temp_c = weather_dict["current"]["temp_c"]
humidity = weather_dict["current"]["humidity"]
condition_text = weather_dict["current"]["condition"]["text"]

print(f"Location: {location}")
print(f"Condition: {condition_text}")
Expand Down

0 comments on commit 315f812

Please sign in to comment.