I have this list in python:
fileTypesToSearch = ['js','css','htm', 'html']
and I want to do something like (using pseudo-javascript):
if (fileTypesToSearch.some(function(item){ return fileName.endsWith(item); }))
doStuff();
What’s the neatest way to do this in python? I can’t find a some function!
In general, you might be looking for
any(), but in this particular case, you only needstr.endswith():will return
Trueif it ends with any of the given extensions.