Doubt Regarding List Comprehension

As seen from the image the i want to remove “-” from the list of list… so first i use for loop on that directly and get the desired output.


Q. but the same i did with the list comprehension it show a list of none
image

why list comprehension is not working in this???

this is because x.remove("-") is not returning anything, it just updates the value of b. In list comprehension you are assigning x.remove("-") to c and since it doesn’t return anything it’s assigning None to c.

In the 2nd part if you print b instead of c, you will see that - has been removed

ohk…thanks…sir