
* 방법 2를 더 많이 사용

while True:
try:
A, B = map(int, input().split())
print(A+B)
except EOFError:
break

import sys
for line in sys.stdin:
A, B = map(int, line.split())
print(A+B)

애초에 for line in sys.stdin이 sys.stdin의 전체 파일에서 한줄(line)씩 읽는 코드이므로
readline()을 하지 않아도 된다.

'백준 - 파이썬 > 단계별 - 3 (반복문)' 카테고리의 다른 글
| [백준/파이썬] 15552번 빠른 A+B | import sys (0) | 2025.04.30 |
|---|---|
| [백준/파이썬] 2439번 별 찍기 - 2 (0) | 2025.04.29 |
| [백준/파이썬] 2438번 별 찍기 - 1 (0) | 2025.04.29 |