Skip to content
    ProductiveResponsibleCarat@cloudyskies2046
    .gitignore
    main.py
    Packager files
    poetry.lock
    pyproject.toml
    Config files
    .replit
    from rich import print
    import requests
    from datetime import datetime


    def display_current_weather(city):
    """Displays the current weather"""
    api_key = "f675a384aa40tc5a0420348fddabad0o"
    api_url = f"https://api.shecodes.io/weather/v1/current?query={city}&key={api_key}"

    response = requests.get(api_url)
    current_weather_data = response.json()
    current_weather_city = current_weather_data['city']
    current_weather_temperature = current_weather_data['temperature']['current']

    print(
    f"Today: {round(current_weather_temperature)}°C.")

    def display_forecast_weather(city_name):
    """Displays the weather forecast"""
    api_key = "f675a384aa40tc5a0420348fddabad0o"
    api_url = f"https://api.shecodes.io/weather/v1/forecast?query={city_name}&key={api_key}"

    response = requests.get(api_url)
    forecast_weather_data = response.json()
    print(f"\n[green bold]{city_name} Forecast:[/green bold]")

    for day in forecast_weather_data['daily']:
    timestamp = day['time']

    date = datetime.fromtimestamp(timestamp)
    formatted_day = date.strftime("%A")
    temperature = day['temperature']['day']

    if date.date() != datetime.now().date():
    print(f"[pink]{formatted_day}[/pink]: {round(temperature)}°C.")


    def credit():
    """Displays the credits"""
    print("\n[yellow]This app was built by Charlie G.[/yellow]")

    def welcome():
    """Displays the welcome message"""
    print("[blue bold]Welcome to my weather app![/blue bold]")
    welcome()

    city_name = input("Enter city name: ")
    city_name = city_name.strip().capitalize()

    if city_name:
    display_current_weather(city_name)
    display_forecast_weather(city_name)
    credit()

    else:
    print("Please try again with a city.")