import requests API_KEY = "YOUR_API_KEY" # šŸ” Replace this with your OpenWeatherMap key def get_emoji(condition): condition = condition.lower() if "rain" in condition: return "šŸŒ§ļø" elif "cloud" in condition: return "ā˜ļø" elif "clear" in condition or "sun" in condition: return "ā˜€ļø" else: return "🌈" def get_weather_by_coordinates(lat, lon): url = f"https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API_KEY}&units=metric" response = requests.get(url) if response.status_code != 200: return "āŒ Could not fetch weather data" data = response.json() temp = data["main"]["temp"] condition = data["weather"][0]["description"] emoji = get_emoji(condition) location = data.get("name", "Selected Location") return f"šŸ“ **{location}**\nšŸŒ”ļø **Temperature:** {temp}°C\nšŸ“Œ **Condition:** {condition} {emoji}"