Hey Everyone! Need some help with this. Sorry this might be stupid for you guys but I was trying hard to figure this out.
This is my code.
total_ask_comments = 0
for comment in ask_posts:
num_comment = int(comment[4])
total_ask_commtents += num_comment
avg_ask_comments = total_ask_comments / len(ask_posts)
print(avg_ask_comments)
this is the error
“ZeroDivisionError: division by zero”
So now, when I review the previous cell and run this code:
ask_posts =
show_posts =
other_posts =
for row in hn:
title = row[1]
if title.lower().startswith(‘ask hn’):
ask_posts.append(row)
elif title.lower().startswith(‘show hn’):
show_posts.append(row)
else:
other_posts.append(row)
print(ask_posts)
the ask_posts is .
What did I miss here? Or what was wrong in my code?
Thanks!