Getting error message "expected an indented block"

Question:

I keep on getting the error message “expected an indented block”

month = int(input('Please enter a month in numeric form: '))
day = int(input('Please enter a day in numeric form: '))
year = int(input('Please enter a two-digit year in numeric form: '))
if month * day == year:
print ('The date is magic!')
else:
print ('The date is not magic.')
Asked By: Kevin

||

Answers:

Indent the code block inside the if statement should fix it.

month = int(input('Please enter a month in numeric form: '))
day = int(input('Please enter a day in numeric form: '))
year = int(input('Please enter a two-digit year in numeric form: '))
if month * day == year:
    print ('The date is magic!')
else:
    print ('The date is not magic.')
Answered By: VietHTran

In Python, indentation is crucial. After each :, you must indent at least at the next line so the interpreter understands the line belongs to the block.

if month * day == year:
    print ('The date is magic!')
else:
    print ('The date is not magic.')

I suggest you to gather more information on how indents work in Python

Answered By: Fukiyel
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.