Python | Check if suffix matches with any string in given list
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