# `str.startswith` supports checking for multiple prefixes: >>> "abcde".startswith(("xyz", "abc")) True # You must use a tuple though, so convert your lists using tuple() >>> prefixes = ["xyz", "abc"] >>> "abcde".startswith(tuple(prefixes)) True