Home / Python Tips Generated By ChatGPT / Checking String Start and End: startswith(), endswith() in Python Check how a string starts or ends. Source Code filename = "example.txt" print(filename.endswith(".txt")) print(filename.startswith("ex"))