Advertisement
xah

Y: Dates

xah
Mar 29th, 2017 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. date = input()
  2.  
  3. while date:
  4.     if date == '0 0 0':
  5.         break
  6.  
  7.     date = date.split(' ')
  8.     date = [int(d) for d in date]
  9.  
  10.     if date[0] > 31:
  11.         print('Invalid')
  12.     elif date[0] == 31:
  13.         if date[1] == 1 or date[1] == 3 or date[1] == 5 or date[1] == 7 or date[1] == 8 or date[1] == 10 or date[1] == 12:
  14.             print('Valid')
  15.         else:
  16.             print('Invalid')
  17.     elif date[0] == 30:
  18.         if date[1] == 2:
  19.             print('Invalid')
  20.     elif date[1] == 2:
  21.         if date[0] == 29:
  22.             if date[2] % 4 == 0:
  23.                 print('Valid')
  24.             else:
  25.                 print('Invalid')
  26.         else:
  27.             print('Valid')
  28.     else:
  29.         print('Valid')
  30.  
  31.     date = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement