[QN] How to convert month name to month number in Python
For a short script I was writing I needed to convert a string representation of the month (“month name”) into a numerical value (“month number”). A quick google led to many solutions to the inverse problem, which to me seems a lot easier. Here is a quick and dirty solution that uses the calendar module.
import calendar
list(calendar.month_name).index(month_name)
I chose to use the calendar module array month_name because I would rather not have to create a list of month names myself.