- 1

Leap Year practice problem in new Python Beginners course

I feel like the question is written incorrectly and the whole thing doesn’t make any sense really. Can someone else take a look and tell me if I’m tripping and if so explain how it works. It seems like it should be easier I’ve already done 2/3 of Python Core so I figure that should be easy

31st Jan 2021, 7:39 PM
Hunter Allen
Hunter Allen - avatar
10 Respostas
+ 1
kole roper Try this leapyear = False year = int(input()) if year % 4 == 0: if year % 100 == 0: if year % 400 == 0: leapyear = True else: leapyear = True if leapyear: print ("Leap Year") else: print ("Not a leap year")
4th Feb 2021, 7:23 PM
AÍąJ
AÍąJ - avatar
+ 1
I have figured it out but thanks for the help. i’m sure the answers will help future people
4th Feb 2021, 8:19 PM
Hunter Allen
Hunter Allen - avatar
+ 1
Pls someone help paste the leap question here.
15th May 2021, 9:46 PM
Samuel Mbah
Samuel Mbah - avatar
0
Hunter Allen There is nothing wrong in that problem. You need to understand again. You have to apply nested if condition to solve problem.
31st Jan 2021, 8:25 PM
AÍąJ
AÍąJ - avatar
0
Ok i will try again thank you
1st Feb 2021, 2:59 PM
Hunter Allen
Hunter Allen - avatar
0
year = int(input()) if year % 4: else: print("Not a leap usae") if year % 100: else: print("Leap year") if year % 400: print("Leap year") else: print("Not a leap year") icant figure out what im doing wrong
4th Feb 2021, 7:44 AM
kole roper
kole roper - avatar
0
thats what i have
4th Feb 2021, 7:44 AM
kole roper
kole roper - avatar
0
please help
4th Feb 2021, 6:37 PM
kole roper
kole roper - avatar
0
You need to read it again and try this code.. year=int(input()) if year%100==0: if year%400==0: print("Leap year") else: print("Not a leap year") else: if year%4==0: print("Leap year") else: print("Not a leap year")
14th Mar 2021, 8:03 PM
Somnath Das
Somnath Das - avatar
0
Just figured it out. Don't need to put the % 100 == 0. year = int(input()) #your code goes here if year % 4 == 0 and year % 100 != 0: print("Leap year") elif year % 400 == 0: print("Leap year") elif year % 400 != 0: print("Not a leap year") else: print("Not a leap year")
4th Feb 2023, 3:43 AM
Dharen Rojan Aguiran Tagalicud
Dharen Rojan Aguiran Tagalicud - avatar