Advertisement
bounslay

Untitled

Apr 28th, 2023
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. # Test case #9: beer time
  2. time = input()
  3.  
  4. hour = time[-8:-6]
  5. minutes = time[-5:-3]
  6. time_designator = time[-2:]
  7.  
  8.  
  9. if hour.isdigit() and minutes.isdigit() and time_designator == 'PM':
  10.     if 1 <= int(hour) < 12:
  11.         print('beer time')
  12.     elif int(hour) == 12:
  13.         print('non-beer time')
  14.     else:
  15.         print('invalid time')
  16.  
  17.  
  18. elif hour.isdigit() and minutes.isdigit() and time_designator == 'AM':
  19.     if int(hour) == 12 or int(hour) == 1 or int(hour) == 2:
  20.         if int(minutes) <= 59:
  21.             print('beer time')
  22.     elif int(hour) >= 3:
  23.         print('non-beer time')
  24.  
  25.     else:
  26.         print('invalid time')
  27. else:
  28.     print('invalid time')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement