Sobes.tech
Intern — Senior

Emulation of the Backspace key action in a line

livecode

Task condition

Write a function backspace(text: str) -> str, which takes a string where the '' character is considered as pressing the Backspace key, deleting the character immediately before it. The function should return a string from which all '' characters and the characters they erase are removed.

def backspace(text: str) -> str:
    ...
    
assert backspace('11111*22222******33*') == '111'
assert backspace('1*289***89fhdf9812heo13*278**') == '89fhdf9812heo1'