Skip to content

Functions · routine

Time of day

Write greeting(name, hour) for an hour from 0 to 23: before 12 return "Good morning, " plus the name, before 18 "Good afternoon, ", otherwise "Good evening, ".

Write a helper part_of_day(hour) first and use it inside greeting.

Run adds print(greeting("Ada", 20)) after your code, to try it.

Stuck on the idea rather than the code? The Functions lesson walks through it.