Not getting correct output


#1

why i'm not getting correct output plz tell me

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


Stocking Out
#2

A dictionary has no value that can be compared.

stock[item] > 0

#3

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

Oops, try again. calling compute_bill with a list containing 1 apple, 1 pear and 1 banana resulted in 4 instead of the correct 7

help me plz


#4

Check the indentation on this line. It should not be inside the loop.


#5

how to run this
n = [3, 5, 7]
def double_list(x):
for i in range(0, len(n)):
x[i] = x[i] * 2

Don't forget to return your new list!

 return x[i]

double_list(n)

Oops, try again. double_list([0, 1]) resulted in an error: list index out of range


#6

You are returning an element that does not exist. Try returning just x.


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.