Skip to content

Commit 703dc8b

Browse files
Update covid.py
1 parent 2014764 commit 703dc8b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

consuming-apis-python/covid.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
# The datetime package is useful to manipulate dates.
44
from datetime import date, timedelta
55

6-
# To fetch the latest total confirmed cases number you need to pass a 24h window to the API.
7-
# That's why you need to pass both yesterday's date and today's.
6+
# To fetch the latest total confirmed cases number you need to pass a 24h
7+
# window to the API. That's why you need to pass both yesterday's date
8+
# and today's.
89
today = date.today()
910
yesterday = today - timedelta(days=1)
1011

@@ -17,8 +18,9 @@
1718
# The response will be a list of results per day, in your case only 1 result.
1819
response = requests.get(endpoint, params=params).json()
1920

20-
# Finally, you need to traverse through the response and increment the `total_confirmed` variable
21-
# with the total number of confirmed cases available that day, which is in the field `Cases`.
21+
# Finally, you need to traverse through the response and increment the
22+
# `total_confirmed` variable with the total number of confirmed cases
23+
# available that day, which is in the field `Cases`.
2224
total_confirmed = 0
2325
for day in response:
2426
cases = day.get("Cases", 0)

0 commit comments

Comments
 (0)