Skip to content

Instantly share code, notes, and snippets.

@zhjgithub
Created November 30, 2017 15:58
Show Gist options
  • Save zhjgithub/035794ecf040f1a9d07b4bc1cddf8ab4 to your computer and use it in GitHub Desktop.
Save zhjgithub/035794ecf040f1a9d07b4bc1cddf8ab4 to your computer and use it in GitHub Desktop.
months = ['January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December']
month_abrrs = dict((m[:3].lower(), m) for m in months) # List comprehensions generator
def valid_month(month):
if month:
month = month.strip()[:3].lower()
if month in month_abrrs:
return month_abrrs.get(month)
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment