Find A Specific Word From A List In Python
So I have a list like below- list = [scaler-1, scaler-2, scaler-3, backend-1, backend-2, backend-3] I want to create another list from it with the words which starts with 'backend
Solution 1:
First off, do not use the name list
for assignment to your objects, you'll shadow the builtin list type.
Then, you can use a list comprehension with str.startswith
in a filter:
new_lst = [x for x in lst if x.startswith('backend')]
Post a Comment for "Find A Specific Word From A List In Python"