name = raw_input("Enter file:")
floor = 0
with open(name) as file:
for line in file:
for character in line:
if character == "(":
floor += 1
elif character == ")":
floor -= 1
print floor
The only thing the second part adds is a 'position' variable and 'if floor == -1' statement, basically. Interested to see where this goes!
View all comments
Show parent comment
1
u/awry_lynx Dec 01 '15 edited Dec 01 '15
my super easy 10-line one in python:
The only thing the second part adds is a 'position' variable and 'if floor == -1' statement, basically. Interested to see where this goes!