python's datetime
object is your friend: Datetime Documentation
It allows you to easily make calculations on dates, including comparisons like you want.
import datetime
date_input = datetime.date(year, month, day)
if date_input > datetime.date(1990, 1, 1) and date_input < datetime.date(1990, 12, 31):
date_input = input('Date: ')
else:
int(input("The date that you enter is not valid, please input a date in between 1/1/1990 and 31/12/1990 "))
Also, if you want user to keep entering dates you may want to do that inside a loop or of course put the input inside date_input
:
def main():
date_input = input ('Date: ')
date_tokens = date_input.split('/')
day = int(date_tokens[0])
month = int(date_tokens[1])
year = int(date_tokens[2])
date_input = datetime.date(year, month, day)
if date_input > datetime.date(1990, 1, 1) and date_input < datetime.date(1990, 12, 31):
date_input = input('Date: ')
else:
int(input("The date that you enter is not valid, please input a date in between 1/1/1990 and 31/12/1990 "))
main()
main()
(I got a bit lazy so I just called main()
again. Same result expect for another "Date: " print)