+ 2
Hello, anyone can explain the raised keyword in python
5 Antworten
+ 6
raised is use to throw an exception 👍
+ 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.😃😃
+ 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
+ 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?
+ 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