my_str="Welcome to plus2net.com"
print(my_str.endswith('com')) # Output is True
print(my_str.endswith('com',4,6)) # Output is False
print(my_str.endswith('com',3,6)) # Output is True
print(my_str.endswith('net',16,19)) # Output is True
print(my_str.endswith('net')) # Output is False
my_str.endswith(search_string,start,end))
search_string : String to be checked at the end of the main string. start: Optional , check to start from this position end : Optional , check to end before this position.
import os
for files in os.listdir('.'):
if files.endswith('.jpg'):
print(files)
All String methods
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.