#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    6
    Rep Power
    0

    System Argument Error In this Code


    I am getting the error for the 'sys.argv[1]' saying "list index out of range". Is there anyway I can fix this?


    Code:
    import sys
    import numpy as np  
    
    N=int(sys.argv[1])        
    a=np.zeros(N+1,int)
    
    a[0]=1
    a[1]=2
    
    for n in range(2,N+1):
        a[n]=((7+(1./n))/(3-(1./n**2)))
        print n,a[n]
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    492
    Rep Power
    33
    Yes, supply arguments when you call the program.. What are you entering to call/run this program?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    6
    Rep Power
    0
    Originally Posted by dwblas
    Yes, supply arguments when you call the program.. What are you entering to call/run this program?
    I want to run a sequence of numbers as defined by the equation in the for loop. What type of arguments are useful for this?
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,856
    Rep Power
    481
    You need lessons in basic shell programming.

    YOU HAVE DIED BY GUI
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo