(Apr-22-2017, 10:50 AM)ichabod801 Wrote: I'm not sure what you need, you've got it all right there. Your paragraph starting with "I know it's going to..." is exactly what I would tell you to do.
There are list and dictionary tutorials in the tutorials sub-forum of this site. I'm sure that you could web search on "python list tutorial" and find more.
Yeah, I guess I should change the subject of the thread to list comprehension lol. I know the logic behind it but I do not know how to write it... :(
I have another question as well pertaining to dicts / lists...
say I have a Inventory lists such as:
stuff = {'rope' : 1, 'torch' : 6, 'gold coin' : 42, 'dagger' : 1, 'arrow' : 12} def displayInventory(inventory): print('Inventory:') item_total = 0 for k, v in inventory.items(): print(str(v) + ' ' + k) item_total += v print('Total number of items: ' + str(item_total)) displayInventory(stuff)and I want to add a list of loot to the inventory dict... the list of loot being:
def addToInventory(inventory, addedItems): # code to add dragonLoot to inventory goes here dragonLoot = ['gold coin', 'dagger', 'gold coin', 'ruby']how would I go about doing so?