์ง์ ๋ ๋ฌธ์์ด์ด ์ธ์๋ก ๋ฐ์ ๋ฌธ์์ด๋ก ์์ํ๋ฉด ์ฐธ(True)๋ฅผ ๋ฐํํ๊ณ , ์ธ์๋ก ๋ฐ์ ๋ฌธ์์ด๋ก ์์ํ์ง ์์ผ๋ฉด ๊ฑฐ์ง(False)๋ฅผ ๋ฐํํ๋ค.
str = 'Hello World!'
>>> print(str.startswith('Hello')
True
>>> print(str.startswith('Hallo')
False
์ง์ ๋ ๋ฌธ์์ด์ด ์ธ์๋ก ๋ฐ์ ๋ฌธ์์ด๋ก ๋๋๋ฉด ์ฐธ(True)๋ฅผ ๋ฐํํ๊ณ , ์ธ์๋ก ๋ฐ์ ๋ฌธ์์ด๋ก ๋๋์ง ์์ผ๋ฉด ๊ฑฐ์ง(False)๋ฅผ ๋ฐํํ๋ค.
str = 'Hello World!'
>>> print(str.endswith('World!')
True
>>> print(str.endswith('World?')
False