python assign list item in for loop code example
Example: python assign list item in for loop
year = 2021
month_list = [1, 2, 3, 4, 5]
day = 1
date_list = []
for month in month_list:
date_list.append( datetime(year, month, day).strftime("%Y-%m-%d") )
print(date_list)
# ['2021-01-01', '2021-02-01', '2021-03-01', '2021-04-01', '2021-05-01']