22 lines
312 B
Python
22 lines
312 B
Python
|
|
def func(wert):
|
|
|
|
if not isinstance(wert,int):
|
|
raise TypeError('weertr muss ein int sein.')
|
|
|
|
if wert >0:
|
|
print('Wert ist in Ordnung')
|
|
else:
|
|
raise ValueError('wert muss größer 0 sein')
|
|
|
|
|
|
|
|
func(7)
|
|
|
|
try:
|
|
func(-1)
|
|
except ValueError:
|
|
print('Da haben wir doch einen falschen Wert übergeben.')
|
|
|
|
|