Skip to content
Advertisement

How can I convert month 6 to June? Is it possible?

Question: How can I convert month 6 to June? Is it possible?

input:
import calendar
y= int(input('Input the year: '))
m=int(input('Input the month: '))
print("Here's the calendar {},{}".format(m,y))
output:
Input the year: 2021
Input the month: 6
Here's the calendar 6,2021

Advertisement

Answer

This would work:

import calendar
y= int(input('Input the year: '))
m=int(input('Input the month: '))
months = {
    1: 'January', 
    2: 'February',
    3: 'March',
    4: 'April',
    5: 'May',
    6: 'June',
    7: 'July',
    8: 'August',
    9: 'September',
    10: 'October',
    11: 'November',
    12: 'December'
}
print("Here's the calendar {},{}".format(months[m],y))
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement