Why did nothing print to the screen when I pressed Run?

@tstone6 print statement is being called in the for statment. remove the indention before you call print. like this:
def compute_bill(food):
total = 0
for item in food:
if stock[item] > 0:
total += prices[item]
stock[item] -= 1
return total
print compute_bill(shopping_list)

i followed the same code but still could not print

Difficult to say what the problem is without actual seeing the code? Maybe also a screenshot so we can see what you see?

If I have done a return total ---- why does print total not work?

There is very little information for us to work with in the question; therefore, we draw assumptions.

  • is the print statement inside the code block, but after return?
  • is the print statement outside of the function, but total a variable of the function?

Sorry, as this question was linked from a specific lesson, I had some assumptions about people knowing the context:

As suspected earlier… print after return.

@tstone6

Yup same with me

Remember that immediately after a return statement is executed, the function is exited. This means that any code written after a return statement will not be executed.

Thank you so much!! I finally got it to print to the console lol. It was that pesky stock**[item]** -= 1