Apr-22-2017, 09:24 PM
You want your return statement in addToInventory to be at the same indentation level as the for loop. That way, it won't execute until the for loop is completely done. As it is now, it executes each time through the loop, so the first time through the loop, it executes and the function ends.
Note that you don't actually need the return statement. Dictionaries are mutable, so when you change inventory in addToInventory, it's also changing stuff in the main program. Basically, stuff and inventory are pointing to the same dictionary. If your next to last line was just:
Note that you don't actually need the return statement. Dictionaries are mutable, so when you change inventory in addToInventory, it's also changing stuff in the main program. Basically, stuff and inventory are pointing to the same dictionary. If your next to last line was just:
addToInventory(stuff, dragonLoot)then it would work without the return statement in addToInventory.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures