Appending a value to a list (List and Dictionaries>Lesson 14)


I am getting an error on Lesson 14: "AttributeError: ‘int’ object has no attribute ‘append’ "

I am fairly certain my code is correct, but it seems that their is an issue with how I am attempting to append the value 50 to the list “Gold”.

Here is my code (the problem seems to be the last line):

inventory = {
‘gold’ : 500,
‘pouch’ : [‘flint’, ‘twine’, ‘gemstone’], # Assigned a new list to ‘pouch’ key
‘backpack’ : [‘xylophone’,‘dagger’, ‘bedroll’,‘bread loaf’]

Adding a key ‘burlap bag’ and assigning a list to it

inventory[‘burlap bag’] = [‘apple’, ‘small ruby’, ‘three-toed sloth’]

Sorting the list found under the key ‘pouch’


Your code here

inventory[‘pocket’] = [‘seashell’, ‘strange berry’, ‘lint’]





It does not work! Even tried copying and pasting - still does not work!


@tortugavaldez[quote=“tortugavaldez, post:1, topic:25603”]



Your error message is [quote=“tortugavaldez, post:1, topic:25603”]
I am getting an error on Lesson 14: "AttributeError: ‘int’ object has no attribute ‘append’ "

Seems cut and dry to me.

If you still do not grasp what I am getting at, an int is not a list.

To add to a value inside of a dict simply add to it, as follows

dict_of_numbers = {'first': 5, 'second': 51}
dict_of_numbers['first'] += 41

# OUTPUT: {'first': 46, 'second': 51}

Easy as pie. If you need anything else feel free to ask.