-1

I know you can strip out white spaces from a string. For example:

abc = " hello everyone "
cba = abc.strip()
print(cba) # output would be "hello everyone" with no spaces either side

However, is it possible to strip characters out of a string? my first initial guess was:

eee = "hello everyone"
rrr = eee.strip(l)

In which I was hoping for the output to be "heo world", but I was met with an error instead

I have also tried replacing.

strip

with:

remove

But still, no luck.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65

1 Answers1

2

I think you're looking for the replace method. So for your example, it'd be:

greeing = "hello everyone"
replaced_version = greeting.replace("l", "")
replaced_version # returns 'heo everyone'
Alex
  • 81
  • 9