Python

Python Menu

Python

Python String endswith() - Definition, Syntax, Parameters, Examples

Definition

The endswith() method returns True if the string ends with the specified value, otherwise False.

Syntax

string.endswith(value, start, end)

Parameters

Parameter Description
value Required. The value to check if the string ends with
start Optional. An Integer specifying at which position to start the search
end Optional. An Integer specifying at which position to end the search

Examples:

myStr = "Hello, welcome to Python tutorials." result = myStr.endswith(".") print(result) # Check if the string ends with the phrase "Python tutorials." result = myStr.endswith("Python tutorials.") print(result) # Check if position 5 to 11 ends with the phrase "Python tutorials." result = myStr.endswith("Python tutorials.", 5, 11) print(result)

Introduction

Python Basics

Python Advance

Data Science Python Tutorials

Python Functions and Methods