I hope I'm not infringing any rule by posting a question not related specifically to any CodeCademy lesson byt Python's syntax.
During my learning I noticed some loops and functions taking arguments or parameters that have never been defined anywhere else in the code. Yet Python understands exactly what data they refer to.
Let's take for example the supermarket lesson.
In Keeping track of your produce we have this bit of code to figure out :
for key in prices: print key print "price: %s" % prices[key] print "stock: %s" % stock[key]
I get that key would easily be interpreted as the key of that dictionary. Yet I can't understand how Python figures out what we mean by prices. Especially when it seems very meticulous on defining values and variables.
Another example, very similar but this time, it's a whole function that takes a paremeter never defined anywhere else and then assign it to a for loop function inside of it:
def compute_bill(food): total = 0 for item in food: if stock[item] >0: total += prices[item] stock[item] -=1 return total
I feel that I'm not yet understanding the mechanism of a parameter and I would love if someone would explain it to me or point me to some reading material on the subject.