Remove Brackets from Expression - Learn Engineering

All the news and updates relevant to Engineering. You can also Write a post here

Breaking

Friday, June 19, 2020

Remove Brackets from Expression

python-mini

Question

To Remove Brackets from given Expression.

Sample TestCaseExpected Output

Enter an Expression : (x+y+z)                                                                               x+y+z


Answer


s=input("Enter an expression : ")
brackets=('()')
for x in s:
    if x in brackets:
        s=s.replace(x," ")
print(s)

No comments:

Post a Comment