fork download
  1. from datetime import datetime
  2. def greetings(name):
  3. hournum=datetime.now().hour
  4. if hournum<12: goodDash="Good marning"
  5. elif hournum<18: goodDash="Good afternoon"
  6. else: goodDash="Good night"
  7. str="\n{goodDash}, {name} I hope you have a great day!"
  8. return str
  9. #function ends, now input
  10. yourName=input("Enter your name: ")
  11. print(greetings(yourName))
Success #stdin #stdout 0.01s 7236KB
stdin
"John Doe"
stdout
Enter your name: 
{goodDash}, {name} I hope you have a great day!