I imagine there is a simple solution that I am overlooking. Better that than a complicated one, right?
Simply put:
var = ['p', 's', 'c', 'x', 'd'].remove('d')
causes var
to be of type None
. What is going on here?
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']
.