I was looking for a one-line way to remove an item from a list and then print the list. The first bit of code works and is straight forward and does what I want:
alist = ["a", "b", "c"]
alist.remove("b")
print(alist)
Which produces the result we want: ["a", "c"]
But when I tried to make it one line:
print(["a","b","c"].remove("b"))
It returns None
. Can someone explain the difference between these? I have seen this question but it does not explain why these produce different outputs, and does not really make it all work in one line.
And this is not actually important for anything, I am just trying to learn what is going on here. Thanks.