In this example:
. Ask for today's date via a form.
. Check if it was typed in dd / mm / yyyy format.
. Compare with the current system date
from datetime import date
def verificacaoData():
dataForm = input('Digite a data atual no padrão dd/mm/aaaa: ')
while True:
if date.today().strftime("%d/%m/%Y") != dataForm:
print('Data informada difere da data atual.')
dataForm = input('Digite a data atual no padrão dd/mm/aaaa: ')
else:
print('Correto! Datas conferem!')
break
verificacaoData()
Is there any other way to do this code avoiding the redundancy of the line below?
dataForm = input('Digite a data atual no padrão dd/mm/aaaa: ')
See working at Repl.it