×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Python
Posted by: Matthew J_
Added: Jun 23, 2022 12:21 PM
Views: 11
Tags: no tags
  1. def remove_chars(string1, chars):
  2.         '''Removes any characters in the chars string from string1'''
  3.         new_string = string1
  4.         for char in chars:
  5.                 new_string = new_string.replace(char, "")
  6.  
  7.         return new_string
  8.  
  9. result = remove_chars('hello world!', 'l')
  10. print(result)   # 'heo word!'