python starts with letter code example

Example 1: javascript string starts with

//checks if a string starts with a word
function startsWith(str, word) {
    return str.lastIndexOf(word, 0) === 0;
}
startsWith("Welcome to earth.","Welcome"); //true

Example 2: 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 3: python string ends with

#!/usr/bin/python

str = "this is string example....wow!!!";

suffix = "wow!!!";
print str.endswith(suffix)
print str.endswith(suffix,20)

suffix = "is";
print str.endswith(suffix, 2, 4)
print str.endswith(suffix, 2, 6)

Example 4: python startswith

str.startswith(prefix[, start[, end]])

Tags:

Php Example