Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 81924ba

Browse files
committed
feat: add logic for Invalid API Key.
1 parent 3dc45ac commit 81924ba

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

projects/API Based Weather Report/API Based Weather Report.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ def main():
114114

115115
# Checking if weather data was successfully fetched
116116
if weather_data:
117+
if weather_data["cod"] == "401":
118+
print("Invalid API key.")
119+
return
120+
117121
if weather_data["cod"] == "404":
118122
print("City not found.")
119123
return

0 commit comments

Comments
 (0)