Futuresony commited on
Commit
713bdd2
·
verified ·
1 Parent(s): fba1b15

Create weather.py

Browse files
Files changed (1) hide show
  1. weather.py +11 -0
weather.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+
3
+ def get_weather(city):
4
+ """Fetch real-time weather from wttr.in"""
5
+ url = f"https://wttr.in/{city}?format=%C+%t"
6
+ try:
7
+ response = requests.get(url).text
8
+ return f"Hali ya hewa katika {city}: {response}"
9
+ except Exception:
10
+ return "Samahani, siwezi kupata hali ya hewa kwa sasa."
11
+