def divide(x, y):
try:
result = x / y
except ZeroDivisionError as e:
print("0으로 나눌 수 없음.",e)
raise
else:
return result
def main():
try:
x = int(input("x: "))
y = int(input("y: "))
try:
result = divide(x, y)
except ZeroDivisionError as e:
print("함수 안에서 예외 발생",e)
else:
print(result)
except ValueError as e:
print("숫자를 넣으세요.",e)
finally:
print("프로그램 종료")
if __name__ == "__main__":
main()
'3-1 > Python 과제&실습' 카테고리의 다른 글
13주차-실습&과제 (0) | 2024.06.13 |
---|---|
12주차-실습&과제 (0) | 2024.05.31 |
11주차-실습&과제 (0) | 2024.05.21 |
10주차-실습&과제 (0) | 2024.05.21 |
9주차-실습&과제 (0) | 2024.05.21 |