Saturday, October 17, 2020

How to remove character form a string in Python

 we can use  replace() method .

x= "ABCDD"

print(x.replace('A',''))

Also we can pass a substring to replace it .

No comments:

Post a Comment

Codeforces problem : C. ABBB, Link : https://codeforces.com/contest/1428/problem/C

 python code:  t=int(input()) while t:     t=t-1; x=input();  stack=[]     for a in x:         stack.append(a) if len(stack)==0 else stack.p...