str.startswith()


Definition
Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position.

Syntax
str.startswith(prefix[, start[, end]]) -> bool

Parameters
str=string
start, end=string

Examples
The returns are following:
 >>> "Adil Waseem".startswith("A")
True
>>> "Adil Waseem".startswith("a")
False
>>>

The return is equal to:
 >>> "Python Lake".startswith("P")
True
>>> "Python Lake".startswith("y")
False
>>> x="Python Lake"
>>> x.startswith("Lake")
False
>>> type(str.startswith)
<class 'method_descriptor'>
>>> dir(str.startswith)
['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__name__', '__ne__', '__new__', '__objclass__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__text_signature__']
>>> str.startswith("Python Lake", "p").__ne__(False)
False
>>> str.startswith("Python Lake", "p").__eq__(False)
True
>>> x=str.startswith("Python Lake", "p")
>>> y=True
>>> x.__gt__(y)
False
>>>

input(webbrowser.open_new())
webbrowser.open_new()
 import webbrowser

x=input("Please enter your web address: ")
y=str(x)

if y.startswith("y"):
    print("Access denied")
    webbrowser.open_new(y)

>>> 
Please enter your web address: yellow.com
Access denied


Comments