Language/Python

[Python] 백준 문제풀이 10951번 - A+B - 4

itorit 2023. 5. 4. 20:35

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

 

10951번: A+B - 4

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

www.acmicpc.net


풀이

list = []

while True:
  # 예외 발생 처리를 위해 try문 사용
  try:
    # 입력 받은 값을 A와 B에 할당한다.
    A, B = map(int, input().split())
    if not 0 < A or not B < 10:
      raise

    list.append([A, B])

  except:
    # int가 아닌값을 입력하거나
    # 위의 if 조건에 맞지않으면 예외발생
    break

for i in list:
  print(int(i[0]) + int(i[1]))