+ 2

Hello, anyone can explain the raised keyword in python

15th Jul 2020, 6:15 AM
Kady
5 Antworten
+ 6
raised is use to throw an exception 👍
15th Jul 2020, 6:16 AM
Shahghasi Adil
Shahghasi Adil - avatar
+ 5
Here is an example to help clarify this even more. try: if 5 > 7 == False: print("5 is greater than 7") else: raise Exception except: print("of course it isn't true") Output: of course it isn't true Silly example 😃 In the above example, the if statement isnt true, so it will raise the exception which is in the except block. Hope this helps.😃😃
15th Jul 2020, 6:33 AM
Tomiwa Joseph
Tomiwa Joseph - avatar
+ 4
Raise keyword is used to raise the exception even if it is removed by except block it will raise the same error which is countered in except block
15th Jul 2020, 7:49 AM
ABHISHEK DHIRANIYA
ABHISHEK DHIRANIYA - avatar
+ 3
Yeah.,but I am not sure when raised happen, i mean the condition in the raised stop dhe program when is the same or when the condition is different?
15th Jul 2020, 6:18 AM
Kady
+ 3
Raise not Raised! It is used to handle errors in a program and it is usually used in a try and except block. Questions like this have been asked before. Please endeavor to use the search bar. Thanks. https://www.sololearn.com/discuss/2175860/?ref=app https://www.sololearn.com/discuss/221589/?ref=app https://www.sololearn.com/discuss/1265497/?ref=app https://www.sololearn.com/discuss/1746199/?ref=app https://www.sololearn.com/discuss/2245372/?ref=app
15th Jul 2020, 6:23 AM
Tomiwa Joseph
Tomiwa Joseph - avatar