给定一个字符串s = "Leonhard Euler",我需要找到我的surname数组中的元素是否是s的子字符串.例如:
s = "Leonhard Euler"
surnames = ["Cantor", "Euler", "Fermat", "Gauss", "Newton", "Pascal"]
if any(surnames) in s:
print("We've got a famous mathematician!")
Run Code Online (Sandbox Code Playgroud)
考虑if any(i in surnames for i in s.split()):.
这将适用于s = "Leonhard Euler"和s = "Euler Leonhard".