exception example 14

This commit is contained in:
Mert Gör 🇹🇷 2023-08-22 14:26:10 +03:00
parent bcdf4e3180
commit 88bd36c361
No known key found for this signature in database
GPG key ID: 2100A876D55B39B9

View 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...')