Python中利用列表编写春夏秋冬(输入月份,输出季节)

题目描述:
1、使用列表编写程序
2、输入一个月份输出它的季节

代码块:

  month = int(input('Month:'))
  if month in [3,4,5]:
      print('春季')
  elif month in [6,7,8]:
      print('夏季')
  elif month in [9,10,11]:
      print('秋季')
  elif month in [12,1,2]:
      print('冬季')
  else:
      print('请输入正确值:')

示例及运行结果:
在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42566251/article/details/94724650
今日推荐