I'm Corinne, and I've never done coding before.
I have to use datetime to call up the time and make a program that changes the greeting depending on the time, so what's the problem?
datetime.hour
is an attribute, not a method. If you use a call expression for something other than a method or function, an error occurs. Almost all languages are common.
https://docs.python.org/3/library/datetime.html#datetime.datetime.hour
Please run the code below:
import datetime
time = datetime.datetime.now()
print(time)
print('time.hour:', time.hour)
# # print('time.hour():', time.hour())
If you read the message carefully, you can see the line and the cause of the error.
TypeError: 'int' object is not callable
is caused by an error of type TypeError
and the int
data type is called as a function... That's what it means.
© 2025 OneMinuteCode. All rights reserved.