You can take the input from the user as a str, then check if it is date in your code and then convert it to a date to check the year and return the day based on the entered year.
Something like the below code, assuming your dataframe name is df
import pandas as pd
from pandas.api.types import is_datetime64_any_dtype
import os
from uuid import uuid4
entered_date= input("Enter a date in 2021 in the formate dd/mm/yy")
## check if it is a date
isDate= is_datetime64_any_dtype(entered_date)
if isDate:
date = pd.to_datetime(entered_date, format='%d-%m-%y', errors='coerce')
year = date.date.today().year
## check the year 2021
if year!=2021:
"The entered date is not in 2021"
else:
print(df.loc[df['date'] == date]['Day'])
else:
"The entered value is not a valid date"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…