【发布时间】:2021-01-03 16:21:10
【问题描述】:
我想拨打给定号码的月份。如果用户输入 1 等,我希望输出类似于“一月份的天数为 30”。
while True:
month_dict = {
"1": "January",
"2": "February",
"3": "March",
"4": "April",
"5": "May",
"6": "June",
"7": "July",
"8": "August",
"9": "September",
"10": "October",
"11": "November",
"12": "December"
}
month = int(input("Enter the number of month:"))
def number_of_date(month):
for value in month_dict.items():
if month in [1, 3, 5, 7, 8, 10, 12]:
print("Number of days in", value, "is 31!!!")
elif month in [4, 6, 9, 11]:
print("Number of days in", value, "is 30!!!")
elif month == 2:
print("Number of days in", value, "is 28!!!")
else:
print("There is not a month like that.. Check your writing!")
number_of_date(month)
【问题讨论】:
标签: python-3.x function dictionary monthcalendar