Why does changing key to item make the code work?


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

Exercise link

<In what way does your code behave incorrectly? Include ALL error messages.>
Code returns “Oops, try again. compute_bill([‘banana’, ‘apple’, ‘orange’, ‘pear’]) returned 8 instead of 10.5” when total +=prices[key]
<What do you expect to happen instead?>
When I change key to item, the code runs. I think it’s because key is checking both dictionaries and referencing stock but the math should be 8.5, not 8 unless python was instructed to return an integer or just rounds down from 5.

What is the ELI5? Does item trigger an action or process or something I just don’t understand yet?

```python

def compute_bill(food):
total = 0
for item in food:
total += prices[item]
return total

<do not remove the three backticks above>

#2

@digitalpro83750
could you provide the FULL code you are using…
and the full failed code you tried to use…