Python startswith() and endswith()


Startswith & Endswith is used to verify if a string starts with a certain sequence of characters and endswith is used to verify if a string ends with a certain sequence of characters

>>> name='joko fani andrianto'
>>> print name
joko fani andrianto
>>>
>>> name.startswith('joko')
True
>>> name.startswith('andrianto')
False
>>>
>>>
>>> name.endswith('andrianto')
True
>>> name.endswith('joko')
False

This function is not return a string rather a boolean (bool) object which is true and false.

Tulis komentar anda... Conversion Conversion Emoticon Emoticon

:)
:(
=(
^_^
:D
=D
=)D
|o|
@@,
;)
:-bd
:-d
:p
:ng
:lv
Thanks for your comment