python-CSD-kursu/python-temel/exception.example.7.py
2023-08-21 19:19:48 +03:00

17 lines
315 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

def foo(a):
print('foo başladı...')
if not isinstance(a, int):
raise TypeError
if a < 0:
raise ValueError
print('foo ok')
try:
foo('ali')
except ValueError:
print('Sayı istenildiği gibi değil!')
except TypeError:
print('Sayı int türden değil!')
print('son...')