Reputation: 141
I have function that takes date as an argument and then turns it into a string but I get this error:
turn_date_into_str(24.09.1873)
^
SyntaxError: invalid syntax
It points to the second dot. Here's my function:
def turn_date_into_str(date_as_dt: date):
res = date_as_dt.strftime("%d.%m.%Y")
return res
Is there a way to actually put date in function's argument?
Upvotes: 0
Views: 610
Reputation: 882
Create and pass date object correctly
from datetime import date
date_obj = date(2022, 5, 8)
res = turn_date_into_str(date_obj)
print(res)
Upvotes: 2