I have 2 lists
- dates and weekdays
>>> dates
['2022-02-08', '2022-02-09', '2022-02-10', '2022-02-11', '2022-02-12', '2022-02-13', '2022-02-14', '2022-02-15']
>>> weekdays
['Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday']
I want to create a json object that looks like this (for eg) for each element in dates
.
myjson = {"label": "Tuesday-2022-02-08", "value": "/inform_date{\"date_list\": \"2022-02-08\"}"}
Basically I want to run a loop where myjson looks like what is given above.
data = []
for i in range(len(dates)):
myjson = {"label": "{0}-{1}".format(weekdays[i], dates[i]), "value": "/inform_date{\"date_list\": \"{}\"}".format(dates[i])}
data.append(myjson)
but I get an error when I run the above for loop.
What is the correct way to build myjson so that it looks just like shown in the example above?