0

Error in code

Any idea what's wrong with the code below? Cheers. year = int(input("Enter Year: ")) if year % 4 == 0 and year % 100 != 0: print(year, "is a Leap Year") elif year % 100 == 0: print(year, "is not a Leap Year") elif year % 400 ==0: print(year, "is a Leap Year") else: print(year, "is not a Leap Year")

20th Dec 2021, 11:55 PM
Stanley
Stanley - avatar
8 Antworten
+ 2
Why did you use ‘year % 100’ thing? You simply could use ‘%4’ thing.
22nd Dec 2021, 6:26 PM
Amber Singh Rathour Pandey
Amber Singh Rathour Pandey - avatar
+ 1
Okay, what do you use for indentation? 2 spaces, 4 spaces, a tab?
21st Dec 2021, 9:35 PM
Slick
Slick - avatar
+ 1
I had no idea about any indentation so the empty spaces were always random within a block and that's why I got the messages. I've just watched some videos and now I know what to do. Thanks for the hint.
21st Dec 2021, 11:33 PM
Stanley
Stanley - avatar
+ 1
That's a mistake. It shouldn't be there.
22nd Dec 2021, 6:59 PM
Stanley
Stanley - avatar
0
What is the error?
21st Dec 2021, 12:43 AM
Slick
Slick - avatar
0
I see nothing wrong with it, and it runs perfectly fine
21st Dec 2021, 6:36 PM
Andrew Johnson
Andrew Johnson - avatar
0
It's okay now but I got the following message yesterday: "expected an indented block" I actually get the same message quite often when doing practice after lessons.
21st Dec 2021, 6:43 PM
Stanley
Stanley - avatar