The kernel appears to have died. It will restart automatically

Screen Link:

https://app.dataquest.io/m/356/guided-project%3A-exploring-hacker-news-posts/1/introduction

My Code:


total_ask_comments = []

for row in hn:
    num_comments = int(row[4])
    for num_comments in ask_posts:
        num_comments += num_comments
        total_ask_comments = num_comments
        
print(total_ask_comments)
print(ask_posts[:1])```

What I expected to happen:


What actually happened: 

The kernel appears to have died. It will restart automatically.


<!--Enter other details below: -->

Also, my Anaconda/Jupyter Notebook instance on Safari doesn't seem to be doing much. My concern is that it's my computer. Thoughts?

hey @davidgarber

Are you still facing this issue? Just to clarify this is happening on your local machine or on the DQ platform?

Based on the above info, have you tried a manual restart of the kernel using these options?

image.

I usually perform a shutdown then restart or logout completely from jupyter and then restart it. and I always work locally.

Good morning. I did “Restart & Run All” and “Restart” both on the DQ page and I got the same response.

My computer is a bit older. What specs should a Mac have to do this course, please?

Thank you,

David

I’ve rebooted and tried it again and I still get this message “The kernel appears to have died. It will restart automatically.” when I run all cells. I would love to know what kind of computer you recommend for this course, please.

hey @davidgarber

I should have asked this earlier, my bad! I don’t have a Mac. Have you tried the page on different browsers instead?

Have you tried searching the error/ issue on google? Maybe you can attach a screen-shot for other Mac users to be able to help you.

Goof morning, Rucha.

I tried it on Chrome and the same thing happened. There is something curious. I can run the following code without an issue:

from csv import reader #importing the csv
opened_file = open('hacker_news.csv')
read_file = reader(opened_file)
hn = list(read_file) #assigning variable hn to the list
headers = hn[0] #Isolating the headers row
hn = hn[1:] #Removing headers row


ask_posts = []
show_posts = []
other_posts = []
no_comments = []

for row in hn:
    title = row[1]
    num_comments = row[4]
    if num_comments == '':
        no_comments.append(row)
    elif 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(len(ask_posts))
print(len(show_posts))
print(len(other_posts))
print(len(no_comments))

The kernel seems to die when I run this new code:

total_ask_comments = 0
num_ask_posts = len(ask_posts)

for row in ask_posts:
    num_comments = int(row[4])
    for num_comments in ask_posts:
        num_comments += num_comments
        total_ask_comments = num_comments
avg_ask_comments = total_ask_comments / num_ask_posts
        
print(total_ask_comments)
print(len(ask_posts))

I’m still concerned that there is an issue with the age of my computer. Is there a minimum requirement for the hardware to take this course?

Thank you,

David

hey @davidgarber

Arghhh! I am an idiot. I just went with the kernel stuff earlier, without really going through your code. :woman_facepalming:

Please stop blaming your computer just because you want to buy a New One! and If you are super rich to do so, please donate this Mac to me! :grin:

What in the Mac World are you trying to do here!? you have sent the code in an infinite loop. Of-course the kernel would die.

when you do this: num_comments += num_comments this is sending the for loop to keep looping till infinity and beyond…

Comment the above lines, take care of the indentation for the below code, and retry. this should work. your code has a problem, not your laptop!