You need to change this:
for class_tup in tup1:
if dropped_class in class_tup[0]:
found = True # now found == True for the rest of the loop
if found:
tup1.remove(class_tup)
to this:
for class_tup in tup1: # incidentally, tup1 is a list not a tuple
if dropped_class in class_tup[0]:
tup1.remove(class_tup)
break # stops the iteration, which seems to be what you are trying to do
Otherwise, you will remove every class_tup
in the rest of the for-loop after you find the dropped_class
in class_tup[0]
.
As a side note, you may want to work on your naming conventions a bit (among other things). For example, tup1
should probably just be courses
or something similar.