string python startswith code example
Example 1: python startswith
text = "Python is easy to learn."
result = text.startswith('is easy')
# returns False
print(result)
result = text.startswith('Python is ')
# returns True
print(result)
result = text.startswith('Python is easy to learn.')
# returns True
print(result)
Example 2: javascript string starts with
function startsWith(str, word) {
return str.lastIndexOf(word, 0) === 0;
}
startsWith("Welcome to earth.","Welcome");
Example 3: python startswith
# str -> the prefix you are looking for
# beg -> where to start looking for the prefix
# end -> where to stop looking for the prefix
str.startswith(str, beg=0,end=len(string))
Example 4: python startswith
str.startswith(prefix[, start[, end]])