Utter newb here with a slowly but surely growing bad reputation. I want to know how my dictionary value char['bag']['Iron Ingot'], or any 'Ingot' for that matter, can be counted without showing a TypeError: 'list indices must be integers or slices, not str.' Counter doesn't seem to work, as it doesn't address the fact I am dealing with a string, not an int, that I want to count. I want to count this string and output an integer value - the number of said string I possess in my list.
char = {'name' : 'Hero',
'lv': 3,
'xp': 0,
'lvnext': 83,
'gp' : 1225,
'bag' : ["Bronze Bastard", "Iron Ingot"],
'stats' : {'ATT': 111,
'DEF': 1,
'WIS': 1,
'hp' : 100,
'atk' : [5,22]}}
def blacksmith():
print("The Master Smith is a giant-like abomination of a demon.")
print("Smith: Bring me ingot, and gold piece, and I will bend the metal to your liking.")
print("[1 ingot per Claw/Claymore/Helm/Gauntlets/Boots, 2 ingots per Bastard/Chain-whip, 4 ingots per Full suit/Liquid coat]")
print("[X ingot(s)] ")
item = input("Assuming you have the ingot and coin, I can make anything forged from the Titanite anvil. (Correctly type the item you want forged.)")
if item == "Iron Claws" and char['bag'].count("Iron Ingot") >= 1 and char['gp'] >= 15:
char['bag'].append(item)
char['bag'] - char['bag']['Iron Ingot']
char['gp'] = char['gp'] - 15
char['stats']['atk'][:] = [x + 1 for x in char['stats']['atk']]
print("{} has been added to your bottomless bag!".format(item))
chapterOne()