0

I can't stop my program in an if statement where I want to check if the number given by the user is a positive one (>0). I get my message if I give a negative number, but the program goes on and shows more messages.

Any idea how to stop it there?

Here is the part I'm trying to fix:

#number validation
if user_age<0 :
    print("Not a valid number")
martineau
  • 119,623
  • 25
  • 170
  • 301
  • 1
    Does this answer your question? [How to terminate a Python script](https://stackoverflow.com/questions/73663/how-to-terminate-a-python-script) – Chris Akridge Mar 20 '21 at 19:57
  • The linked duplicate is a brute-force hammer that solves the problem as asked; but you should instead try to write your code in a way that there just isn't anything else that happens afterward. Some useful tools for this are `return`ing from a function that contains the main work of the script, and using the matching `else` for your `if`. – Karl Knechtel Mar 20 '21 at 19:59

0 Answers0