python NameError: name 'memberno' is not defined
Question: my code is giving me the error of

    
    
    Destination[index]=inode*dof-dof
    IndexError: list assignment index out of range
    

I have searched for this error but i cant figure out the problem in this
code.Please help me...

    
    
    import numpy as np
    
    class memberdata(object):
        def__init__(self,memberno=None,backnode=None,forenode=None,materialno=None):
            self.memberno=memberno
            self.backnode=backnode
            self.forenode=forenode
            self.materialno=materialno
    member=[]
    member.append(memberdata('10','2','3','1'))
    
    print "enter dof"
    dof=raw_input()
    dof=int(dof)
    def get_destination(memberno):
        inode = member[memberno-1].backnode
        inode=int(inode)
        jnode = member[memberno-1].forenode
        jnode=int(jnode)
        Destination=[]  
        index=0
        Destination[index]=inode*dof-dof
        for i in range(dof):
            index=index+1
            Destination[index]=Destination[index-1]+1
        index=index+1
        Destination[index]=jnode*dof-dof
        for i in range(dof):
            index=index+1
            Destination[index]=Destination[index-1]+1
    
    
    if __name__ == "__main__":
        get_destination(memberno)
    


Answer: 
    Destination=[]  
    index=0
    Destination[index]=inode*dof-dof
    

Here, you create an empty list with `[]` and then try to assign index 0, where
`Destination[0]` doesn't yet exist. The list holds 0 values, hence any index
you try to assign will be out of range.

If you simply want to add some value to the list, use

    
    
    Destination.append(inode*dof-dof)
    

