["python","assert","raise"]
What's the difference between raise, try, and assert?

I have been learning Python and the raise function* and assert are really similar (what I realised is that both of them crash the app, unlike try - except) and I can't see a situation where you would use raise or assert over try. So, what is the difference between raise, try, and assert? * Editor's note: It's a statement, not a function.
Assert Used when you want to "stop" the script based on a certain condition and return something to help debug faster: list_ = ["a","b","x"] assert "x" in list_, "x is not in the list" print("passed") #>> prints passed list_ = ["a","b","c"] assert "x" in list_, "x is not in the list" print("passed") #>> Traceback (most recent call last): File "python", line 2, in <module> AssertionError: x is not in the list Raise Two reasons where this is useful: 1. To be used with try and except blocks Raise an error of your choosing - could be custom like below and doesn't stop the script if you pass or continue the script; or can be predefined errors raise ValueError() class Custom_error(BaseException): pass try: print("hello") raise Custom_error print("world") except Custom_error: print("found it not stopping now") print("im outside") Output: hello found it not stopping now im outside Notice it didn't stop? We can stop it using just exit(1) in the except block. 2. Re-raise raise can also be used to re-raise the current error to pass it up the stack to see if something else can handle it. except SomeError as e: if not can_handle(e): raise handle(e) Try/Except blocks Does exactly what you think: tries something, and if an error comes up, catches it and deals with it however you like. No example since there's one above.