Closed chasekeir closed 1 year ago
First, I'll just say that you asked this question in a fantastic way. You gave me the entire error message and all the relevant pieces of code, and you formatted everything properly with code blocks. This makes it very easy for me to find the problem and help.
The key here is the exception you are getting
TypeError: 'Comment' object is not callable
indicates that you are putting parentheses next to something that's not a function. (We covered this in the exceptions quiz if you need to go back and review exactly why that's the error.)
The line causing this error is
random_comment.reply(body=generate_comment())
and there's exactly two uses of ()
here: one on random_comment.reply
and the other on generate_comment
. One of these two things must not actually be a function, but a Comment
object.
I agree that both of these things "should" be a function, but somewhere you must have redefined one of them to be something else. To see exactly which one is causing the problem, you can separate it out into two lines like
text = generate_comment()
random_comment.reply(body=text)
My guess is that you'll find that the error now happens on the first line and not the second. This would most likely be caused by a line somewhere else in your code that redefines the generate_comment
function to be something else. This likely looks something like
generate_comment = ....
and you'll have to find and fix the above line.
Hi Mike,
I am running my code for task #4 in bot.py:
for context here is my code for task #3
Here is the error message I am receiving:
How can I fix this?