endswith(): Checks matching string ending

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.

Check if given string ends with input search_string , returns True if string ends with input search_string otherwise false

Example

Display all image files or files with extension .jpg of current directory.
import os
for files in os.listdir('.'):
    if files.endswith('.jpg'):
        print(files)
All String methods


Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer