Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Python

Idiom #168 Trim suffix

Create string t consisting of string s with its suffix w removed (if s ends with w).

t = s.removesuffix(w)

removesuffix is in Python 3.9+
using System;
string t = s.TrimEnd(w);

New implementation...
programming-idioms.org