Write a Logic to Validate only this partten (()), ((), )(
Code Example
#Write a Logic to Validate only this partten (()), ((), )(
user_input = input("enter here :")
stack = [i for i in user_input]
for j,i in enumerate(user_input):
if i == ')':
if stack.index(')') > stack.index('('):
stack.remove('(')
stack.remove(')')
if ')' in stack or '(' in stack:
print("no")
else:
print("yes")
Comments
Post a Comment