- 2

Leap year project.

How to write leap year project in python??

27th Nov 2021, 2:45 AM
khizar
khizar - avatar
7 Réponses
+ 4
You need examples and inspirations? Code Playground is a good place to begin the search 👍
27th Nov 2021, 2:57 AM
Ipang
+ 3
First try to solve the task yourself. Show what your problems are. Otherwise a ready-made solution is googled in a couple of seconds.
27th Nov 2021, 2:59 AM
Alexey Kopyshev
Alexey Kopyshev - avatar
27th Nov 2021, 3:20 AM
Simon Sauter
Simon Sauter - avatar
+ 3
It's already good try. You just forgot to complete the if-else constructions if year%4 == 0: if year%100 == 0: if year%400 == 0: print("leap year") else: #something here else: #something there else: print("not a leap year") Ps. for sure you can combine ALL conditions in long one
27th Nov 2021, 3:46 AM
Alexey Kopyshev
Alexey Kopyshev - avatar
+ 1
khizar First, correct the indentation. Python identifies blocks by their indentation, so having it wrong breaks everything. Read the lessons on blocks or if statements. Second, correct variables and commands casing. if, then, else, print, and almost every command or function is lower case. Also, you assign a value to variable "Year", but then call variable "year". Finally, the code doesn't output when year is multiple of 4 but not leap. My advice: use a single "if" statement and combine conditions with boolean operators.
29th Nov 2021, 12:53 AM
Emerson Prado
Emerson Prado - avatar
0
Year = int(input()) If year % 4 == 0: If year % 100 != 0: If year % 40p == 0: Print ("leap year") Else: Print ("not a leap year")
27th Nov 2021, 3:24 AM
khizar
khizar - avatar
0
But this code doesn't work
27th Nov 2021, 3:24 AM
khizar
khizar - avatar