How to strip a set of characters from a string in Python

1 Answer

0 votes
def strip_chars(str, chars):
    return "".join(ch for ch in str if ch not in chars)
    
    
s = "Python is general purpose programming language"

s = strip_chars(s, "aeiou")

print(s)




'''
run:

Pythn s gnrl prps prgrmmng lngg

'''

 



answered Sep 3, 2021 by avibootz
...