17.
nts
Write a python code that takes month number as an input and display the corresponding month
name as an output.(if elifjelse). If user enters wrong input then display error message
Answers
Answered by
1
from datetime import date
def month_name(n):
months = dict([(i, date(2021, i, 1).strftime('%B')) for i in range(1, 13)])
return months[n] if n in months else "invalid input"
print(month_name((n := int(input("num: ")))))
Similar questions