Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate a list of the months of the year in Python
'''
Generate a sorted list with the months of the year
'''
import datetime
months = [datetime.date(2000, m, 1).strftime('%m - %B') for m in range(1, 13)]
print months
'''
print months
['01 - January', '02 - February', '03 - March', '04 - April', '05 - May', '06 - June', '07 - July', '08 - August', '09 - September', '10 - October', '11 - November', '12 - December']
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment