say for example the first 5 apples you buy cost .50 and the next 5 apples you buy after that cost .40 and every apple after that is .30.

How would I go about creating a function that could tell okay apples 1-5 cost .50 then add any extra in range 5-10 for the value of .40 and then every apple after that costing .30?

Does this functionality have to be incorporated in the function itself? It doesn't seem like something you'd want to use a function for at all. The functions are meant to not be aware of the global operations of the program, so it's not straightforward to have the function be aware of an iterable in the main program. Why exactly to you wan to use a function?

Yes this is just 1 function out of 4.. this one receives the values from function 1 then relays them to the 4th function and so on. It is part of a hw assignment i am working on.

This is what I have so far. It produces the right answer but it just feels real clunky.

gearboxes=30

if (gearboxes<=10):
        cost=gearboxes*100.0
        print cost
elif (gearboxes>10 and gearboxes<20):
        cost=(gearboxes-10)*80.0+1000.0
        print cost
elif (gearboxes>20):
        cost=(gearboxes-20)*70.0+1000.0+800.0
        print cost
else:
        print "wtf m8"