파이썬을 서브 언어로 해서 코테 문제를 풀던중
새로 알게 된 사실.
예전까지는 변수 값과 문자열을 같이 출력하고 싶을 때,
단순히 print() 문 안에 변수와 문자열을 + 처리를 해줘서 아주 간단하게 출력해주었다.
그러나 파이썬도 다른 언어와 같이 % s % d % f도 지원해준다고 한다.
예를 들어 이렇게.
print("%d %d " % (zero_count[m], one_count[m])) # 변수 2개이상을 출력하고 싶을때는 이렇게 괄호로 묶어서 처리해주면 된다.
이외에도 여러 가지 방식의 출력이 있으니,
앞으로 답을 출력할 때 다양한 방식으로 출력이 가능할 것 같다.
728x90
반응형