The startswith()
method tells whether a certain string A starts with a string B.
string_A = "What do i begin with?"string_B = "What"print ( string_A.startswith(string_B) ) # startswith() call
Optionally, you can add 2 more arguments. This gives you the power to see whether a very specific part within a string A starts with a string B.
These arguments are the starting and ending indices of this “specific part”.
string_A = "What do i begin with?"string_B = "at"print ( string_A.startswith(string_B, 2, 6) ) #startswith() call
Free Resources