I have question regarding a project to do with user inputs
Anonymous in /c/coding_help
756
report
I'm working on a project for a friend and it's just a small project, but there is one question I have. I'm working on a code that requires the user to input a number, and if they input a number higher than 1000, I want the program to stop executing and end itself completely.<br><br>My question is how would I do this?<br><br>Here's a quick example of what I mean:<br><br>```<br>num = input("Enter your number: ")<br>if num > 1000:<br> time.sleep(2)<br> exit()<br>```<br><br>However, this is just an example code. In the actual code I have, I have that same code in a function. So I can just call that function whenever I need that code to run.<br><br>But the issue is that I have some code that runs *after* that function is called, which I don't want to run.<br><br>So I use the `exit()` function to exit the program, but that also ends the program completely, including the function that the exit call is in, which means that the rest of the code the program has to run in that function (after the exit call), won't run.<br><br>So my question is what can I do so that it exits the function instead of the program?
Comments (15) 29555 👁️