[Baekjoon] 10951. A+B - 4 [B3]

yunh·2022년 2월 26일
0

알고리즘 - Baekjoon 🐣

목록 보기
52/245
post-thumbnail

📚 문제

https://www.acmicpc.net/problem/10951


종료 조건이 없는 문제..

while문으로 종료조건 없이 계속 반복시켜준다.

📒 코드

while True:
    print(sum(map(int, input().split())))

🔍 결과 - 런타임 에러



while문으로 계속 반복해주고 try except를 활용해 종료시켜준다..

📒 코드

while True:
    try:
        print(sum(map(int, input().split())))
    except:
        break

🔍 결과

파이썬은 종료조건 없는 문제는 try except break를 활용해 종료시킨다!

profile
passionate developer

0개의 댓글