What does the builtin function any() do?

I did some google searching on how to check if a string has any elements of a list in it and I found this bit of code that works:

if any(i in string for i in list):

I know this works, but I don’t really know why. Could you share some insight?


Source: syntax

Leave a Reply