본문 바로가기

Coding Test

백준 10951번 - while문 탈출

문제 : 두 정수 A와B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.

→ 입력이 끝날 때까지 A+B를 출력하는 문제

 

 

EOFError 예외처리

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

입력 도중에 파일의 끝(End of File)을 만나면 EOFError가 발생

'Coding Test' 카테고리의 다른 글

백준 2884번, 2525번 - if문  (0) 2022.02.23
백준 1110번 - while문  (0) 2022.02.19
백준 8393, 2741, 2742 - for문  (0) 2022.02.17
백준 15552번 - sys.stdin.readline()  (0) 2022.02.13
백준 2588번 - %, range, list  (0) 2022.02.08