Exit python program when argument is less than 0
        Posted  
        
            by Sam
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Sam
        
        
        
        Published on 2010-03-30T23:01:16Z
        Indexed on 
            2010/03/30
            23:03 UTC
        
        
        Read the original article
        Hit count: 231
        
python
I'd like the program to exit if the input number is less than 0, but sys.exit() isn't doing the trick. This is what I have now:
if len( sys.argv ) > 1:
    number = sys.argv[1]
if number <= 0:
    print "Invalid number! Must be greater than 0"
    sys.exit()
© Stack Overflow or respective owner