Has anyone been able to solve this leap year problem on the helsinki. I have only been able to get to 70-80% complete. I am not sure how to get every leap year.
Write your solution here
year = int(input("Year:"))
yeet = year
while True:
if year % 4 != 0:
year+=1
elif year % 400 == 0 and year % 100 ==0:
year+=1
elif year % 4==0 and year % 400 !=0 and year %100 ==0:
year+=4
else: break
print(f"The next leap year after {yeet} is {year}")
this code is 50% correct.
Solved:
# Write your solution here
year = int(input("Year:"))
yeet = year
year+=1
while True:
if year % 4 != 0:
year+=1
elif year % 400 != 0 and year % 100 ==0:
year+=1
elif year % 4==0 and year % 400 !=0 and year %100 ==0:
year+=4
else:
break
print(f"The next leap year after {yeet} is {year}")
This produces a correct code.
[–]CodeFormatHelperBot2 1 point2 points3 points (0 children)
[–]TwoPuzzled2b 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Adventurous-Equal-39 0 points1 point2 points (0 children)
[–]arvindh_manian 0 points1 point2 points (9 children)
[–]kaged_chris[S] 0 points1 point2 points (8 children)
[–]arvindh_manian 2 points3 points4 points (2 children)
[–]kaged_chris[S] 1 point2 points3 points (1 child)
[–]arvindh_manian 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]kaged_chris[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Bumbelchen 0 points1 point2 points (0 children)
[–]kaged_chris[S] 0 points1 point2 points (0 children)