startswith() String Method in Python with Examples

startswith() is standard string method in python to check whether a string starts with some pre-specified string or not.

startswith() method returns True if string starts with the specified prefix, otherwise it returns False.

startswith() Python Example


message = 'Welcome to Python!'
print(message.startswith('We'))
print(message.startswith('WE'))

startswith() Example Output

True
False


Related String Methods