You take money on the school trip, and your snack list's prices are in prices, in order. Buy from the first one, and stop at the first you cannot afford, skipping the rest. Write items_bought(prices, money) to return how many you bought.
items_bought([3, 5, 2], 10)→3items_bought([4, 8, 1], 10)→1items_bought([], 5)→0def items_bought(prices, money):
count = 0
for price in prices:
# your code here: not enough money, break;
# otherwise pay (take price off money), add 1 to count
pass
return count
Run tries the examples. When they look right, Submit.