[SW Expert Academy, SWEA 14555] 공과 잡초 (python)
Problem Solving/SWEA

[SW Expert Academy, SWEA 14555] 공과 잡초 (python)

728x90

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AYGtoa3qARcDFARC&categoryId=AYGtoa3qARcDFARC&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=3&pageSize=10&pageIndex=1

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com


※ SW expert 아카데미의 문제를 무단 복제하는 것을 금지합니다.

728x90

# 테스트 케이스의 수 t
t = int(input())

for test_case in range(1, t + 1):
	s = input()

	result = 0
	i = 0
	while(i < len(s)):
		if s[i] == '(':
			if s[i + 1] == ')':
				result += 1
				i += 1
			else:
				result += 1
		elif s[i] == ')':
			result += 1
		i += 1

	print("#{} {}".format(test_case, result))
728x90