Python script sys.argv error
Question: This is my first python script:

    
    
    #!/usr/bin/env python
    # Years till 100
    import sys
    
    name = sys.argv[1]
    age = int(sys.argv[2])
    diff = 100 - age
    
    print 'Hello', name + ', you will be 100 in', diff, 'years!'
    

When I run it, it gives the following error:

    
    
    name = sys.argv[1]
    IndexError: list index out of range
    

Can anyone help me spot the problem please?


Answer: I found that I was not executing the program properly.

I was doing the following:

    
    
    $ chmod u+x pytest3_variable1.py
    $ ./pytest3_variable1.py 
    

I should have done:

    
    
    $ chmod u+x pytest3_variable1.py
    $ ./pytest3_variable1.py Abhinav 22
    

