exception example 14
This commit is contained in:
parent
bcdf4e3180
commit
88bd36c361
13
python-temel/exception.example.14.py
Normal file
13
python-temel/exception.example.14.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
class MyError(Exception):
|
||||
pass
|
||||
|
||||
try:
|
||||
a = int(input('Bir değer giriniz:'))
|
||||
if a < 0:
|
||||
raise MyError()
|
||||
print(a * a)
|
||||
except ValueError:
|
||||
print('Girilen değer geçersiz!')
|
||||
except MyError:
|
||||
print('Sayı negatif!')
|
||||
print('ends...')
|
Loading…
Reference in New Issue
Block a user