python-any function; determine whether the elements in the array exist in the string

code:

city=['Shenzhen','Shanghai','Beijing','Hangzhou']

address='My family lives in Hangzhou, China'

if any(element in address for element in city):

print("The string "%s" contains the string "%address" in the city)

output:

Guess you like

Origin blog.csdn.net/weixin_43934631/article/details/129183640