0

I want to replace multiple specific character with the function replace for example :

INPUT :(c#d)&(a#b)&(k>m)

output : should be #(c,d)&#(a,b)&(k>m)

but it work only for one input #(c,d)&(a#b)&(k#m)

this is my code

inr=str(input('entrer : '))    

inr = inr.replace('(a#b)','#(a,b)') or inr.replace('(c#d)','#(c,d)')
print(inr)
0

1 Answer 1

2

You can use replace twice:

inr.replace('#',',').replace('(','#(')

#(c,d)&#(a,b)&#(k,m)
Sign up to request clarification or add additional context in comments.

11 Comments

how about if the formula is (a>b)&(c#d)&(k|r)
you want the same change?
Yes the same change but the out put should be specific only for (c#d) ==> #(c,d) not for all formula
if you run the same code, you get undesired result?
Yes the code is applied to all the formula
|