def remove(self, idx: int) -> Option[u]: try: _ = self[idx] del self[idx] return some(_) except IndexError: return none
def rsplit_once(self, u: u) -> Option[(str, str)]: opt_idx = self.rchar_index(u) if opt_idx is none: return none first, last = self.split_at(opt_idx.unwrap()) last.remove(0) return some((str(first), str(last)))
def rchar_index(self, u: u) -> Option[int]: try: return some(len(self) - 1 - self[::-1].index(u)) except ValueError: return none
def char_index(self, u: u) -> Option[int]: try: return some(self.index(u)) except ValueError: return none
def pop(self) -> Option[u]: try: return some(super().pop()) except IndexError: return none