

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 10
click for more info
Not enough gems
Cost: 6 gems
1: Stacks
incomplete
2: Stack Speed
incomplete
3: Pop and Peek
incomplete
4: Stack Review
incomplete
5: Using a Stack
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
LockedIn supports a basic scripting language. It allows technically savvy HR managers to write scripts that can automate repetitive tasks on the platform. The language makes use of parentheses to group operations together, and we need to be able to check if the parentheses in a script are balanced.
Parentheses are balanced when each parenthesis has a corresponding parenthesis, and the pairs of parentheses are properly nested. For example:
()()()((()))(()(()))(())(()()(())))(As you scan the string, consider what each item on the stack should represent.
Complete the is_balanced function.
It takes a string as input and returns True if the parentheses in the string are balanced, and False otherwise. Use an instance of the provided Stack class in stack.py to keep track of the parentheses.
If the parentheses are balanced, then the stack should be empty.
You only need to consider the characters ( and ) for this challenge.