Python怎么能让count=3在第一行年份在第二个行

img

img


怎么让count能计数?还要让3在第一行,都会输出 就是没法让计数3第一行

i只保存了最后一个闰年,用列表保存所有闰年并输出,星号去括号


def is_leap_year(year):
    if year%4==0 and year%100!=0 or year%400==0:
        return True
b,c=map(int,input().split())
count=0
d=[]
for i in range(b,c+1):
    if is_leap_year(i) is True:
        count+=1
        d.append(i)
print(count)
print(*d,sep=" ")

img

我不明白你的代码里count怎么就不在第一行了
放个图出来看看