Computer Science, asked by rishikakasturi, 2 months ago

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 jai696
1

\huge\red{\mid{\fbox{\tt{Using\: Python\: 3}}\mid}}

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: ")))))

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions