Python ProgrammingPython Programming

How I can get the month name from the month number?

# Python's program to get the month name from the month number

import calendar
import datetime

# Month name from number
print("Month name from number 5:")
month_num = 1
month_abre =, month_num, 1).strftime('%b')
month_name =, month_num, 1).strftime('%B')
print("Short Name:", month_abre)
print("Full  Name:", month_name)

print("\nList of all months from calendar")
# Print list of all months from calendar
for month_val in range(1, 13):
    print(calendar.month_abbr[month_val], "-", calendar.month_name[month_val])

Sample output of above program.
C:\programs\time>pep8 --first

Month name from number 5:
Short Name: Jan
Full Name: January

List of all months from calendar
Jan - January
Feb - February
Mar - March
Apr - April
May - May
Jun - June
Jul - July
Aug - August
Sep - September
Oct - October
Nov - November
Dec - December