I am new to python, and have been doing a beginner's course on it.
I came across this piece of code during one of the lecture:
import datetime
DOB=input("Enter the DOB:")
CurrentYear=datetime.datetime.now().year()
CurrentAge=CurrentYear-int(DOB)
if(CurrentAge>=18):
print("Your Age is {} and you are Adult".format(CurrentAge))
if(CurrentAge<18):
print("Your Age is {} and you are not Adult".format(CurrentAge))
print("Condition has been verfied successfully")
This course that I am doing is from ~2018, and the instructor didn't have any error while compiling this code.
datetime.datetime.now().yearis an int but you dodatetime.datetime.now().year()- so you try to treat this int as a function