pyhton startswith function 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: string startswith python

# 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))