endswith() function in python by R4R Team

-endswith()is a python string function which check the string ending point and return True and False as per the argument.

Example-

string is s="mytext"
s.endswith("t") will give True
s.endswith("xt") will give True
s.endswith("text") will give True
s.endswith("my") will give False

program-

s="someway"
print("Original string is ",s)
print(s.endswith("y"))
print(s.endswith("Hii"))
print(s.endswith("Y"))
print(s.endswith("way"))
print(s.endswith("someway"))


output-

Original string is someway
True
False
False
True
True


-In this program, string "someway" is ends with the "y" and "way" and "someway" so it will give True but in case of "Hii" and capital "Y" it will give False.

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!