I need to save all the list items starting with 'S' from list l to l2
l= ['Santa Cruz','Santa fe','Sumbai','Delhi']
l1 = []
l1 = list(map(lambda x : x if x[0] == 'S',l))
print(l1)
Above has resulted in an syntax error.
I tried Trial-I
l= ['Santa Cruz','Santa fe','Sumbai','Delhi']
l1 = []
l1 = list(map(lambda x : x if x[0] == 'S' else '',l))
l1
and it returns [True, True, True, False]
my expected output is ['Santa Cruz','Santa fe','Sumbai']
Trial-II
l= ['Santa Cruz','Santa fe','Sumbai','Delhi']
l1 = []
l1 = list(map(lambda x : x[0] == 'S',l))
print(l1)
Trial-II returned ['Santa Cruz','Santa fe','Sumbai', '']
my expected result should not have the blank list item in the ending.