I just want to write a script for taking the date as input from user,if user don't enter date then program should take system's date. I tried the following code.How can I do this using any if-else condition or functions in python.
date_entry = input('Enter a date in YYYY-MM-DD format:')
year, month, day = map(int, date_entry.split('-'))
date1 = datetime.date(year, month, day)
How can I write this script for above problem.I am new to python.
Aucun commentaire:
Enregistrer un commentaire