Skip to content

Instantly share code, notes, and snippets.

@jangeador
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jangeador/f3e4691a239ede6921e1 to your computer and use it in GitHub Desktop.
Save jangeador/f3e4691a239ede6921e1 to your computer and use it in GitHub Desktop.
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