about | help | code help+videos | done | prefs |
is_balanced
Write a function, is_balanced, that will return True if its input is a string that has balanced parentheses. "Balanced" means that the string has the same number of left parentheses, "(", and right parentheses, ")". But furthermore, they must come in pairs, "(" matched to a following ")", so that "()" is balanced, but ")(" is not. The string may contain any number of non-parenthesis characters; those don't matter. is_balanced('()') → True is_balanced(')(') → False is_balanced('((x+1) * (x-1))') → True ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy