Second Guided Project : Hacker News

Hello, I’m finished my second project, please let me know your comments and observations, thank you.

https://app.dataquest.io/m/356/guided-project%3A-exploring-hacker-news-posts/8/next-steps

Basics(1).ipynb (29.8 KB)

Click here to view the jupyter notebook file in a new tab

1 Like

Hi @jemartinezm1,

You have done a great job. You have gone further to analyse the data and came to a better conclusion. Nicely done.
Also the use of pytz library is great. I’m going learn from your code.

I have one question though. I’ve been thinking about this swap_list when I saw it in the instructions.If we are appending average and then the hour to the list, cant we sort the list straightaway, without creating another list to swap? What do you think?

Hi @jithins123, I don’t know if we can swap without the swap list, I tried in the previous project the solution below, but it requires create a function, thank you for your review.

# take second element for sort
def takeSecond(elem):
    return elem[1]

# random list
random = [(2, 2), (3, 4), (4, 1), (1, 3)]

# sort list with key
random.sort(key=takeSecond)

# print list
print('Sorted list:', random) 

https://www.programiz.com/python-programming/methods/list/sort