Given a list of strings, the task is to check whether suffix matches with any string in the given list.
Input: lst = ["Paras", "Geeksforgeeks", "Game"], str = 'Geeks' Output: True Input: lst = ["Geeks", "for", "forgeeks"], str = 'John' Output: False
Let’s discuss a few methods to do the task.
Method #1 : Using
The most concise and readable way to check whether suffix exists in list of strings is to use any().
Initial List is : ['Paras', 'Geeksforgeeks', 'Game'] True
Method #2 : Using
This is yet another way to perform this particular task using lambda().
Initial List is : ['Paras', 'Geeksforgeeks', 'Game'] False
- Python | Check if string matches regex list
- Python | Find all close matches of input string from a list
- Python | Check if string ends with any string in given list
- Python | Program that matches a word containing 'g' followed by one or more e's using regex
- Python - Extract Indices of substring matches
- Python - Remove suffix from string list
- Python | Check Numeric Suffix in String
- Python | Segregate list elements by Suffix
- Python | Append suffix/prefix to strings in list
- Python - Suffix List Sum
- Python - Suffix Product in list
- Python | Check if any String is empty in list
- Python - Check if string starts with any element in list
- Python | Convert List of String List to String List
- Python | Check if any element occurs n times in given list
- Python | Merging two strings with Suffix and Prefix
- Python - Find Keys with specific suffix in Dictionary
- Python | Extract suffix after K
- Python - Substring Suffix Frequency
- Python - Swap K suffix with prefix
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.