Lambda, map function

lst1 = [1, ‘b’, 2, ‘b’, 3, ‘b’, 4]
for char in lst1:
if char == ‘b’:
lst1.remove(‘b’)
print(lst1)

can we use map function to simplify this script. I have just started learning python. Could anyone please help???

I am new to python and not really answering your question. I got it working similar to what you have with this:

list = [1, ‘b’, 2, ‘b’, 3, ‘b’, 4]
val = ‘b’
while val in list:
list.remove(‘b’)
print(list)

I am trying to figure out how to use the map function based on the video in the training but can’t figure out a second argument. Will come back if I figure something out.

I googled around as well and can find things about using mapping to replace certain character, but not on removing characters.

I have not found way with map yet, but I found a way with list comprehension. Although it doesn’t really shorten the code.