I just tried to display my birthday(dd/mm/yyyy). And then, I got "ValueError" which is like "time data %r does not match format %r" % and "time data ' 01/27/1998' does not match format '%d/%m/%y'"
Here is my code
from datetime import datetime, timedelta
birthday = input('When is your birthday (dd/mm/yyyy)?')
birthday_date = datetime.strptime(birthday, "%d/%m/%y")
print('Birthday : ' + str(birthday_date))
one_day = timedelta(days=1)
birthday_eve = birthday_date - one_day
print('Day before birthday : ' + str(birthday_eve))
This is the detail of error
When is your birthday (dd/mm/yyyy)? 01/27/1998
Traceback (most recent call last):
File "010-input_date.py", line 5, in <module>
birthday_date = datetime.strptime(birthday, "%d/%m/%y")
File
"C:\Users\Kohei\AppData\Local\Programs\Python\Python38\lib\_strptime.py",
line 568,
in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File
"C:\Users\Kohei\AppData\Local\Programs\Python\Python38\lib\_strptime.py",
line 349,
in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data ' 01/27/1998' does not match format '%d/%m/%y'