-1

Given this string, ###hi##python##python###, how can I remove all instances of '#'?

v = "###hi#python#python###"
x = v.strip("#")
print(x)

Expected output: "hipythonpython"

gmds
  • 19,325
  • 4
  • 32
  • 58

2 Answers2

1

Just use replace

the_str = '###hi##python##python###'
clean_str = the_str.replace('#','')
print(clean_str)

Output

hipythonpython
balderman
  • 22,927
  • 7
  • 34
  • 52
0

What you want is not strip, but replace:

v = '###hi#python#python###'
x = v.replace('#', '') 

print(x)

Output:

hipythonpython
gmds
  • 19,325
  • 4
  • 32
  • 58