Removing item from list causes the list to become NoneType

remove doesn’t return anything. It modifies the existing list in-place. No assignment needed.

Replace

var = ['p', 's', 'c', 'x', 'd'].remove('d') 

with

var = ['p', 's', 'c', 'x', 'd']
var.remove('d') 

Now var will have a value of ['p', 's', 'c', 'x'].

Leave a Comment