0
Problem solving
Phython
6 Respuestas
+ 1
Do you have a code to attach as your attempt
That way, we can help easier
+ 3
Nemezio Lopezperez
I sent you a DM with a code that reflects the challenge line for line.
I hope it helps you understand the underlying concept of the challenge
+ 2
Last part of if has to be
... or year%400==0:
With and it can never be true
Code with testing:
def leap(year):
if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
print("Leap year")
else:
print("Not a leap year")
for y in range(395,405):
print(y, end=' ')
leap(y)
for y in range(495,505):
print(y, end=' ')
leap(y)
+ 2
Thanks Benjamin that corrected it !!
0
Hi guys! Trying to solve this problem for Phython but not finding a way to get through it, maybe someone could help? Much appreciated 🙏💪👌
You need to make a program to take a year as input and output "Leap year" if it’s a leap year, and "Not a leap year", if it’s not.
To check whether a year is a leap year or not, you need to check the following:
1) If the year is evenly divisible by 4, go to step 2. Otherwise, the year is NOT leap year.
2) If the year is evenly divisible by 100, go to step 3. Otherwise, the year is a leap year.
3) If the year is evenly divisible by 400, the year is a leap year. Otherwise, it is not a leap year.
0
Hey yes this was my attempt:
if year % 4 == 0 and year % 100 != 0 and year % 400 == 0:
print("Leap year")
else:
print("Not a leap year")