2.使用列表编写一个程序,用户输入一个月份,程序输出该月份对应的英文单词。
时间: 2024-05-24 08:10:26 浏览: 10
month = ["January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"]
num = int(input("请输入一个月份的数字:"))
if num < 1 or num > 12:
print("输入的数字不合法!")
else:
print("该月份对应的英文单词是:", month[num-1])
相关问题
用Python2.使用列表编写一个程序,用户输入一个月份,程序输出该月份对应的英文单词。
month_list = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
month_number = input("Please enter a month number (1-12): ")
print(month_list[int(month_number)-1])
用Python.使用列表编写一个程序,用户输入个月份,程序输出该月份对应的英文单词。
month_list = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
month_number = int(input("请输入月份(1-12):"))
if month_number >= 1 and month_number <= 12:
print(month_list[month_number-1])
else:
print("输入有误,请输入1-12之间的数字。")
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)