Good day to all! I ask for your help, there is a code:
import requests from datetime import datetime, date, time city = input() r = requests.get('http://api.openweathermap.org/data/2.5/forecast?&units=metric&q=%s&appid=295f286d77a869327ed8dfae72a0542d' % (city)) data = r.json() temp = data["list"] for id in temp: tmp = id["main"]["temp"] tmp = str(round(tmp)) dt = id["dt_txt"] print(dt + " - " + tmp + "°C") Which by the name of the city gives the weather for 5 days. That only gives it periods of 3 hours. Those. for 24 will give 8 values. 5 days - 40
To set the displayed number of values, I can write temp = data["list"][*number*] in the code. The problem is that the weather is displayed depending on the time, i.e. if I run the script at 18, it will show the weather from 18:00. If I start at 9 am, it will show from 9 am. Proceeding from this, I cannot set in temp = data["list"] [8] as the weather will appear not only for today, but also for tomorrow. And constantly, based on the time, I do not have to enter the required number of output values.
How can I make a check that if until the end of today there are 6 hours left, then in temp = data["list"] to betray the value [2] . If it remains 12 hours - then pass [4] .
I would be very grateful for your reply.

data = [id for id in temp if start_time <= id['dt'] < end_time]- jfs