Question of [] and ()


#1

Hello!! I am ne in this so sorry if the question is too simple:

I used in this
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

But it seems I have to use [] and I don´t get why. Can someones please Explain it to me?
Thanks!!!
Fernanda


#2

square brackets are used for accessing by index (string and list) and key (dictionaries)

parentheses are used for functions and function calls, understanding when to use what is fundamental at this point in the course


#3

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