Sometimes, while working with String list, we can have a problem in which we need to remove the surrounding stray characters or noise from list of digits. This can be in form of Currency prefix, signs of numbers etc. Let’s discuss a way in which this task can be performed.
Method : Using list comprehension +
strip() + isdigit() + join()
The combination of above functions can be used to perform this task. In this, we strip the stray characters from numbers that are identified from the strings and return the result.
The original list : ['-4', 'Rs 25', '5 kg', '+15'] List after removing stray characters : ['-', '4', 'Rs', '25', '5', 'kg', '+', '15']
- Python | Split list of strings into sublists based on length
- Python | Split strings in list with same prefix in all elements
- Python | Split CamelCase string to individual strings
- Python | Convert List of String List to String List
- Python | Split string into list of characters
- Python - Split String of list on K character
- Python | Split flatten String List
- Python | Remove all digits from a list of strings
- Python | Remove empty strings from list of strings
- Python | Tokenizing strings in list of strings
- Python | Split Sublist Strings
- Python | Reversed Split Strings
- Python | Ways to split strings on Uppercase characters
- Python | Ways to split strings using newline delimiter
- Python - Selectively Split in Strings
- Python - Split Strings on Prefix Occurrence
- Python | Convert list of strings and characters to list of characters
- Python | Convert list of string to list of list
- Python | Split given list and insert in excel file
- Python | Split and Pass list as separate parameter
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.