When moving house, things go into boxes in order, each box holding at most cap kilos (10 if not given). If the next thing won't fit in the current box, take a new one. Write count_boxes(weights, cap) to return how many boxes you need. Nothing weighs more than cap; nothing to pack means 0.
count_boxes([4, 5, 3, 6])→2count_boxes([])→0def count_boxes(weights, cap=10):
boxes = 0
current = 0
for w in weights:
# your code here: if there's no box yet or w won't fit, take a new box (boxes + 1, current back to 0), then put w in
pass
return boxes
Run tries the examples. When they look right, Submit.