In: Computer Science
Write a program in date_generator.py that generates all the dates of next year in mmm dd, yyyy format, as shown below. You need not calculate whether 2021 is a leap year--it is NOT.
If you want to see a hint, scroll WAY down!
Jan 1, 2021 Jan 2, 2021 Jan 3, 2021 . . . Dec 30, 2021 Dec 31, 2021
***my teachers hint:My solution to this program is quite short, but the code is not super simple. I used two lists, a for-loop nested inside another for-loop, range and enumerate.
Please do this in python
Code:
year=2021
months=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
#list for months
days=[31,28,31,30,31,30,31,31,30,31,30,31]
#list for days in that particular month
for i in range(12):
#This loop iterates 12 times from 0 to 11
for j in range(1,days[i]+1):
#This loop iterates for days in that partivular month
print("{} {}, {}".format(months[i],j,year))#Here we print the mmm
day, year
Output:
.
.
.
.
.
.
.
Indentation: