#Checking for number of comments in ask_posts
total_ask_comments = 0
for posts in ask_posts:
num_comments = int(posts)
total_ask_comments += num_comments
avg_ask_comments = sum(total_ask_comments)/len(ask_posts)
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.
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.
The response I got from Isuepb has solved the challenge.
You’re welcome Could you please mark my answer as solution? I would appreciate a lot.