Indentation is leading whitespace that Python uses to determine which lines of code belong together. It is required inside functions, if statements, and for or while loops; incorrect indentation changes the program’s behavior or causes an error. section 5.1.2
Conditionals and nested blocks
In an hour-based greeting, the morning and afternoon messages belong to their conditional branches. The evening message must be indented under else; otherwise, it prints for every hour. A loop nested inside a function requires another indentation level. section 5.1.2
hour = int(input('Please enter the current hour from 0 to 23: '))
if hour < 12:
print('Good morning!')
print('Have a nice day.')
elif hour < 18:
print('Good afternoon!')
else:
print('Good evening!')
print('Have a good night.') #1
Inspect the greeting code and identify why the final message executes regardless of the entered hour. section 5.1.2





