3
In this example:
. Request today’s date via a form.
. Check if typed in dd/mm/yyyy format.
. Compare to 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 make this code avoiding the redundancy of the line below?
dataForm = input('Digite a data atual no padrão dd/mm/aaaa: ')
See working on Repl.it
Interesting! Always found the
return
would only work by returning the value of, for example, a variable.return media
– Lucas Braga