You should declare variable ctLowShelfLife =0
before the loop begins.
UPDATE
The problem is with your indentation. Your code should be like this ,
>>> def calcItemsLowShelfLife(shelfLifeList):
ctLowShelfLife = 0
for number in shelfLifeList:
if number <= 7:
ctLowShelfLife += 1
return ctLowShelfLife
>>> shelfLifeList = [5, 7, 10]
>>> lowShelfLife = calcItemsLowShelfLife(shelfLifeList)
>>> lowShelfLife
2
>>>