how to deal with list index out of range in if?
<pre><code>class student:
    def __init__(self,name,course,course_hastaken):
        self.name=name
        self.course=course
        self.taken=course_hastaken

    def takeclass(self):        
        for j in range(len(Course_of_study)):
            if people[i].course==Course_of_study[j]:
                print(Course_of_study[j])
                if Degree_requirement[j] == []:
                    print(people[i].name + " You can take this course")
                else:
                    Requirement =Degree_requirement[j]
                    #print(Requirement)
                    for k in range(len(people[i].taken)):
                        q=people[i].taken
                        for l in range(len(Degree_requirement[j])):
                            p=Degree_requirement[j]
                            if q[k]==p[l]:
                                print(Requirement)
                                print(p[l])
                                Requirement.remove(p[l])
                    if Requirement == []:
                        print("You can take this course")
                    else:
                        print(people[i].name+" Sorry, you can't take this class.")


Course_of_study=["a","b","c","d","e","f","g","h","i"]
Degree_requirement=[["b","g"],[],["d","h","i"],[],["f","b","i"],[],[],[],[]]
people=[student("Jake","a",["b","g","c"]),student("Leo","b",["d","e"]),student("Eric","c",["d"])]
for i in range(len(people)):
    people[i].takeclass()
</code></pre>

<p>My question is that i find that Required actually has q[l], but it is still showing that list is out of range. I print out the p[l] and requirement does has that in the list but when i type in the remove, the program just go wrong. </p>

<p>The program shows that there is something wrong with the </p>

<pre><code>Requirement=Requirement.remove(p[l])
</code></pre>