So, I was making a text-based "shopping" program, and I came across an error that didn't quite make sense to me. The error message was this:
TypeError: can't multiply sequence by non-int of type str
Here is a code snippet of where I think the error is located (Comment above line where I believe error to be located):
def buy():
print "\nType in a store item to buy."
find_item = raw_input(prompt)
if find_item in store_items:
print "Amount?"
amount = raw_input(prompt)
if amount:
#Error in next line?
store_rec.append(store_items[find_item] * amount)
get_buy()
If you're wondering, store_items is a dictionary containing the store items like this:
store_items = {
"carrot": "carrot",
"apple": "apple",
"pear": "pear",
"taco": "taco",
"banana": "banana",
"tomato": "tomato",
"cranberry": "cranberry",
"orange": "orange",
}
Then store_rec is an empty list, like this:
store_rec = []
It contains recommendations for telling the user what to buy next time, but that's not where I think the error is located. What I was trying to do in the line where the error appears to be, is append the amount of items specified by the user to the empty store_rec list. Unfortunatly, then I get the error. It seems like it should work, but it doesn't. So, with that in mind, any help on my problem is appreciated!