gustavorsantos
Published in

gustavorsantos

Check the start or end of a string

Use startswith() or endswith() for strings

Are you familiar with the .startswith( ) and .endswith( ) methods for strings?

These built-in Python functions function similarly to MS Excel’s function “MID”.

Its syntax is simple, requiring only to input the string to be checked and it has optional start and end points of the verification in the text.

The return is a Boolean value: True or False.

my_str.startswith( ‘string’, start, end )

Image by the author

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gustavo Santos

Data Scientist. I extract insights from data to help people and companies to make better and data driven decisions. | In: https://www.linkedin.com/in/gurezende/