python string starts with any char of list

Solutions on MaxInterview for python string starts with any char of list by the best coders in the world

showing results for - "python string starts with any char of list"
Ornella
05 Mar 2018
1# `str.startswith` supports checking for multiple prefixes:
2>>> "abcde".startswith(("xyz", "abc"))
3True
4# You must use a tuple though, so convert your lists using tuple()
5>>> prefixes = ["xyz", "abc"]
6>>> "abcde".startswith(tuple(prefixes))
7True