python统计闰年的个数_一个月内检查闰年和计算天数的代码

这是我的代码:def cal(month):

if month in ['January', 'march','may','july','august','oct','dec']:

print ("this month has 31 days")

elif month in ['april','june','sept','nov']:

print ("this month has 30 days")

elif month == 'feb' and leap(year)== True:

print ("this month has 29 days")

elif month == 'feb' and leap(year) == False:

print ("this month has 28 days")

else:

print ("invalid input")

def leap(year):

if (year % 4== 0) or (year % 400 == 0):

print ("its a leap year!")

else:

print ("is not a leap year")

year = int(input('type a year: '))

print ('you typed in :' , year)

month = str(input('type a month: '))

print ('you typed in :', month)

cal(month)

leap(year)

我收到的输出:

^{pr2}$

如果是28天或29天,为什么我没有得到2月份天数的输出?在

为什么我得到无效的输入部分,即使它是另一个?在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值