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.')
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.')
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
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.')
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.')
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