Type Error Occured in python executed in visual studio -


i running below code calculate current age in python using visual studio.

but getting below piece of error: error:

type error occured unsupported operand type built_in_function or method 

code:

import datetime  def my_current_age():     user_input = input("enter year")     date_of_birth = (datetime.date(1990 , 10 , 28))     today_date=(datetime.date.today)     current_age = (today_date - date_of_birth)     print("you lived {}" .format(current_age))   print(my_current_age()) 

any suggestion python developer please

thanks

you assigning method of datetime today_date with:

today_date=(datetime.date.today) 

i.e, calling function. call it, instead:

today_date=(datetime.date.today()) 

in order work.

apart that, take note parenthesis around expressions redundant, is:

today_date=(datetime.date.today()) 

is directly equivalent to:

today_date = datetime.date.today() 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -