QuickSnip LogoA light blue logo with a thunderbolt in bracketsQuickSnip

Remove Characters

Removes specific characters from a string.

  • string
  • remove
  • characters

Code

def remove_chars(s, chars):
    return ''.join(c for c in s if c not in chars)

Usage

remove_chars('hello world', 'eo') # Returns: 'hll wrld'