Python | Remove trailing / leading special characters from a list of strings

Method: Using map () + str.strip ()
Combining the above two functions can help us solve this particular problem. In this case, we use strip () , which has the ability to strip trailing and leading special unwanted characters from a list of strings.  map () , used to extend the logic for each item in the list.

# Python3 code to demonstrate how it works
# Remove trailing / leading special characters from the list of strings
# Using map () + str.strip ()

 
# initializing list

test_list = [ `gfg` , `is` , `best` ]

 
# print list

print ( " The original list: " + str (test_list))

 
# Remove trailing / leading special characters from the list of strings
# Using map () + str.strip ()

res = list ( map ( str . strip, test_list))

 
# Print result

print ( "List after removal of special characters:" + str (res))

Output:

 The original list: [`gfg`, `is`, `best`] List after removal of special characters: [`gfg`,` is`, `best`]