Help: string conversion to int not working

I’m trying to convert from string to int in a guided project exploring hacker news post and it’s not working. this is the code

total_ask_comments =0

for rows in ask_posts:
** num_comments = int(rows[4])**
** total_ask_comments = total_ask_comments + num_comments**
avg_ask_comments = total_ask_comments / len(ask_posts)

print(avg_ask_comments)

total_show_comments =0

for rows in show_posts:
** num_comments = int(rows[4])**
** total_show_comments = total_show_comments + num_comments**
avg_show_comments = total_show_comments / len(ask_posts)

print(avg_show_comments)

and this is error i am getting “ValueError: invalid literal for int() with base 10: ‘h’”

Nevermind seen my error.

How did you correct the error? I’m getting the same one and can’t see what I’m doing wrong.

My ask_post and show_post variables were pointing to the title column only instead of the entire row.

2 Likes