[Tutor] Bothersome NoneType Error for a List object

Steven D'Aprano steve at pearwood.info
Wed Jul 4 18:15:08 CEST 2012


Osemeka Osuagwu wrote:

>             templist = templist.append(prime)

The append method operates in place, and returns None. It doesn't return a list:

py> mylist = []
py> x = mylist.append(42)
py> x is None
True
py> mylist
[42]

Replace that line with just

templist.append(prime)


-- 
Steven


More information about the Tutor mailing list