Python3 endswith() Method | Tutorial
Tutorial -- Learning is not just about technology, but also about dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
Python 3 Tutorial
Python3 Tutorial Python3 Introduction Python3 Environment Setup Python3 VScode Python3 Basic Syntax Python3 Basic Data Types Python3 Data Type Conversion Python3 Interpreter Python3 Comments Python3 Operators Python3 Numbers Python3 Strings Python3 Lists Python3 Tuples Python3 Dictionaries Python3 Sets Python3 Conditional Statements Python3 Loops Python3 First Program Python3 Comprehensions Python3 Iterators & Generators Python3 with Python3 Functions Python3 lambda Python Decorators Python3 Data Structures Python3 Modules Python __name__ Python3 Input & Output Python3 File Python3 OS Python3 Errors & Exceptions Python3 OOP Python3 Namespace/Scope Python Virtual Environment Creation Python Type Hints Python3 Standard Library Overview Python3 Examples Python Quiz
Python3 Advanced Tutorial
Python3 Regular Expressions Python3 CGI Programming Python MySQL - mysql-connector Driver Python3 MySQL Database Connection - PyMySQL Driver Python3 Network Programming Python3 SMTP Sending Email Python3 Multithreading Python3 XML Processing Python3 JSON Data Parsing Python3 Date & Time Python3 Built-in Functions Python MongoDB Python3 urllib Python uWSGI Installation & Configuration Python3 pip Python3 operator Module Python math Module Python requests Module Python random Module Python OpenAI Python Useful Resources Python AI Drawing Python statistics Module Python hashlib Module Python Quantitative Python pyecharts Module Python selenium Library Python Web Scraping - BeautifulSoup Python Scrapy Library Python Markdown to HTML Python sys Module Python Pickle Module Python subprocess Module Python queue Module Python StringIO Module Python logging Module Python datetime Module Python re Module Python csv Module Python threading Module Python asyncio Module Python PyQt Python for Loop Python while Loop
Python3.x Python3 endswith() Method
Description
The endswith() method is used to check if a string ends with a specified suffix. It returns True if the string ends with the specified suffix, otherwise it returns False. The optional parameters start and end specify the start and end positions for the search within the string.
Syntax
The syntax for the endswith() method is:
str.endswith(suffix[, start[, end]])
Parameters
suffix-- This parameter can be a string or a tuple of strings.start-- The start position within the string.end-- The end position within the string.
Return Value
Returns True if the string contains the specified suffix, otherwise returns False.
Example
The following examples demonstrate the use of the endswith() method:
Example
#!/usr/bin/python3
Str = "Tutorial example....wow!!!"
suffix = "!!"
print(Str.endswith(suffix))
print(Str.endswith(suffix, 20))
suffix = "run"
print(Str.endswith(suffix))
print(Str.endswith(suffix, 0, 19))
The output of the above example is as follows:
True
True
False
False
YouTip