0

Can anybody explain what a raise exception is and what is the difference between it and try....except?

raise exception in python

4th Oct 2017, 7:41 PM
Zahraa
Zahraa - avatar
3 Respuestas
+ 7
There was a thread about it just very recently, check it out: https://www.sololearn.com/discuss/758398/?ref=app
4th Oct 2017, 8:39 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
I haven't really touched Python so far but raise exception might be what essentially "throws" or raises the exception (creates one). Try is probably which handles (catches) the raised exceptions in its scope.
4th Oct 2017, 7:59 PM
Norbivar
Norbivar - avatar
+ 1
try: command1 except: command 2 if the command you write under try is an error: it will execute command under except. raise will make your program error print("hello world") raise KeyboardIntetrupt will causing error
5th Oct 2017, 4:23 AM
Kevin AS
Kevin AS - avatar