Advertisement
bounslay

Untitled

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