编写一个函数 find_longest_common_prefix,该函数可以接受任意数量的字符串参数,并返回它们的最长公共前缀。
例如,find_longest_common_prefix("hello", "hell", "heaven") 应该返回 "he",find_longest_common_prefix("python", "pyramid", "py") 应该返回 "py"。
def find_longest_common_prefix(*words):
if not words:
return ""
prefix = words[0]
for word in words[1:]:
while not word.startswith(prefix):
prefix = prefix[:-1]
if not prefix:
return ""
return prefix