It's dangerous to go alone


#1

https://www.codecademy.com/courses/python-beginner-en-pwmb1/2/5?curriculum_id=4f89dab3d788890003000096

I have problems with the sort comand and I don't know why?
The error message says: Oops, try again. Did you remember to sort the list at inventory["backpack"]?

I thought i sorted it in line 16....


#2

Hello

We can not link directly to your exercise.

I can make a suggestion and ask if you added the sort at the back of that inventory list?

An example would be -

suitcase['shoes'].sort()


#3

You think? Find out. And then you can either see that you did not, or see that you did, and therefore rule that out.


#4

This is what i did to sort the backpack list:

inventory['backpack'].sort()

Why doesn't it work?


#5

Hello

The error displays inventory["backpack"] with double quotes, you have single quotes. Try it.
I ran your code line, it worked. I also put it in double quotes & it worked.
If my above suggestion does not work, send me that section of code please. We can not link to your lesson directly.

Thanks.


#6

wow the last part with the gold was pretty tricky, cant the key gold hold more then one int?
i could have a few pieces of gold like 50, 550?! or im overthinking here?

anyway i got it solved.


#7

this is my code, it doesn't work:

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'

inventory['pouch'].sort()

Your code here

inventory['pocket'] = ['seashell','strange berry','lint']
inventory['backpack'].remove('dagger')
inventory["backpack"].sort()
inventory['backpack'].append(50)


#8

Hello

We want to add 550 to 'gold'
inventory['gold']..... not backpack.

Also the instructions state - Add 50 to the number stored under the 'gold' key.

Hope that helps. Let me know.


#9

Hi,

Find below code which is the correct one.

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'

inventory['pouch'].sort()

Your code here

inventory['pocket'] = ['seashell', 'strange berry', 'lint']
inventory['backpack'].sort()
inventory['backpack'].remove('dagger')
inventory['gold'] = inventory['gold'] + 50


#10

I have this problem so I need some help.


#11

Most of what you've done is correct, but line 14 has a syntax error and line 16 and 17 has spelling errors.
'pocket' should be formatted the same way as 'burlap bag' in line 8.


#12

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.