Could not perform stock out, dear coders please help!


#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.>
https://www.codecademy.com/en/courses/python-beginner-en-IZ9Ra/2/3?curriculum_id=4f89dab3d788890003000096#

<In what way does your code behave incorrectly? Include ALL error messages.>
File “python”, line 22
SyntaxError: can’t assign to operator

<What do you expect to happen instead?>

successful execution

```python shopping_list = ["banana", "orange", "apple"]

stock = {
“banana”: 6,
“apple”: 0,
“orange”: 32,
“pear”: 15
}

prices = {
“banana”: 4,
“apple”: 2,
“orange”: 1.5,
“pear”: 3
}

Write your code below!

def compute_bill(food):
total = 0
for items in food:
if stock[items] > 0:
total = prices[items] + total and stock[items] = stock[items] - 1
return total

<do not remove the three backticks above>

#2

Hi @srinath_92 ,

Evidently, you are trying to combine two assignment statements with a & operator here …

total = prices[items] + total & stock[items] = stock[items] - 1

Instead, you need to use two separate statements.


#3

thank :slight_smile: :slight_smile: :slight_smile:
this bit of code worked correctly without the use of and operator

def compute_bill(food):
total = 0
for item in food:
if stock[item] > 0:
total = total + prices[item]
stock[item] = stock[item] - 1
return total


#4

Hello Pythoners,

UPDATE reading through many other posts on the same topic someone else found the answer that works: simply delete the print command from the end, doing so removes the bug in the system and allows you to move on!