Important Notice:

Course Content
The Calendar Module
Library Function/Predefined Functions
0/4
Sys Module
Library Function/Predefined Functions
0/2
OS Module
Library Function/Predefined Functions
0/2
Functions in Python (Chapter-10) M3-R5
About Lesson

endswith():-

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

Syntax:-                       string.endswith(value, start, end)

Parameter

Description

value

Required. The value to check if the string starts 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

 

txt = “Hello, welcome to my world.”

x = txt.endswith(“.”)

print(x)

Output

True

txt = “Hello, welcome to my world.”

x = txt.endswith(“my world.”)

print(x)

Output

True

txt = “Hello, welcome to my world.”

x = txt.endswith(“my world.”, 5, 11)

print(x)

Output

False

error: Content is protected !!