I am stocked at the stage 4

#Checking for number of comments in ask_posts
total_ask_comments = 0
for posts in ask_posts:
num_comments = int(posts[4])
total_ask_comments += num_comments
avg_ask_comments = sum(total_ask_comments)/len(ask_posts)
print(avg_ask_comments)

When I run this code it pop up an error

TypeError “int” not iterable.

When I print(total_ask_comments)
It print an output.

I don’t know what could be the cause.

Hello @onyidojohn, could you post a link to the mission?

Also, it is important to properly format your code so it’s easier for people to understand it. You can see how to do this in the Technical Question Guidelines.

Asking a good question increases your chances of receiving a fast, accurate answer.

2 Likes

Hey, onyidojohn . Welcome to Dataquest Community.

I think the error is when you are defining the avg_ask_comments variable. It should be like this:

avg_ask_comments = total_ask_comments / len(ask_posts)

You just have to remove the sum() function since the total_ask_comments variable is not a list. It should work then.

Hope I could help.

1 Like

Okay noted.

The response I got from Isuepb has solved the challenge.

Thank you

2 Likes

Yes it did.

Thank you

1 Like

You’re welcome :grinning: Could you please mark my answer as solution? I would appreciate a lot.