When I try to convert nonetype variable to string it does not change? Is there any better way to store dates? [closed]
I was making a program to store dates in an Excel sheet to make a task simpler, and then I encountered this confusion of how to generate or how to store dates from which I can easily write them to the Excel sheet.
I have provided the code below if anyone wants to try:
to_day = int(input("Enter the day today: "))
to_month = int(input("Enter the month: "))
to_year = int(input("Enter the year you are in: "))
today_date = print(to_day, "-", to_month, "-", to_year)
str_todaydate = str(today_date)
print(type(today_date))
Solution 1:
print
returns None
, not the string that got printed. Change this:
today_date = print(to_day, "-", to_month, "-", to_year)
to this:
today_date = f"{to_day}-{to_month}-{to_year}"
print(today_date)