Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

list.remove() returns None. So it is a mistake to bind its return value to allbut2.

It follows the convention that methods that modify their object inplace should return None. list.pop() is an obvious exception.

You create a new list via list comprehension instead of copying and then removing:

  even = [i for i in L if i % 2 == 0] # remove odd numbers


I believe he meant:

    all = range()
    allbut2 = all
    allbut2.remove(2)
which is something that catches people all the time.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: