Ok. I got through your code. Hard piece of work.
As mtf said:
Try to give names that make sense and are clear to understand. Of course so that people can easily help you and don't have to put too much time and afford into it, else it will annoy them and you will be stuck without getting help. AND it's not only for us but you also will get confused if your code gets a little longer than just 10-20 lines. So create good habits as long it is easy. But enough with scolding, let's go to your code:
train.remove(goll and gall) You can't nest (is this the right verb?) commands. What your code do is:
evaluate goll and gall -> 6. train.remove(6) so it removes the bigger(?) item in your list (I don't know why;maybe someone else can help eg mtf). So there is only one item removed. What you need is this:
Next: your definition of gol and gal belonges into the while loop; if not and you get a list with 6 items you end up with only remove two of them:
[1,2,3,4,5,6] ` //please note that this is not real code!`
remove goll and gall
[2, 3, 4, 5]
while loop still active but goll and gall are 1 and 6 which are not in your list and can't be removed!
Last but not least:
sup+=(sap//2.0) is incorrect because: assum [4, 5, 5, 4] -> you will be left with [4, 5] ->
9//2=4; 2 goes 4 times in 9 (floor division); What we need here is a normal division: 9/2 will be also 4, but because of integer division
9/2 is 4.5, since we are in python2 you get the integer of 4.5 which is 4 so what we should do
float(9)/2 -> 4.5 CORRECT ANSWER! so our code is:
sup+=(float(sap)/2); by the way '=' is enough, since sup is 0.
so Our code is working properly.... For even lists!
For the next list ([6, 8, 12, 2, 23]) in the test it fails:
goll = hop
gall = hop[len(hop)-1]
train.append(hit in hop) `// hit is called before it is assigned!`
But to be hones I don't what to get into this, too, because I have to re-code the whole loop for this and I fear it will not be the last flaw.
So in general:
Your approach is working but way to complicated. Try to keep it simple. Try another approach.
I hope I could help