Python Lists and Dictionaries


#1

What's wrong with my code ?
Please help !


#2

The error says, "Unexpected indent", which is your problem. Un-indent the last four lines.


#3

There should be no indent on lines 14-17. I think you still have to be more specific and add 'pocket' to inventory. For example
inventory['pocket']= ..........
look at line 8 of your code. Thats basically the answer for step 1


#4

Can you get me the correct program @cadecodes @jasoncheung94


#5

Nope. Asking for correct code is against community guidelines.


#6

Bruh !! Fine.. Then help me somehow.. I've been stuck in this problem for a month !

Even this gives me a error !


#7

It is right, backpack isn't defined. It is a key (HINT) in the inventory dictionary. :slightly_smiling:


#8

How do I define it ?


#9

The point of not giving out solutions is that if you can't produce them yourself then there's something important that you need to learn. If you don't want to learn that thing whatever it is, then you've got no business asking for help either.

Your next error says that backpack isn't defined - so either you missed defining it or you should be accessing something else.


#10

You're skipping a step. Should it be defined at all? Take some time to read and understand the code and the instructions.

How is the backpack represented in the code? And how can you manipulate that?


#11

What is still wrong ?


#12

Now you are re-assigning inventory. Think about what the problem is. It certainly isn't the inventory.


#13

I'm still not able to get it !!


#14

THINK about what the error is saying...


#15

Do you see the variable backpack defined anywhere?
What does it look like when a variable is created?
If there's no variable called backpack, then trying to use it is pointless. So, how is the backpack represented in the code?


#16

Finally......
Did it..
Thanks @cadecodes @ionatan !!


#17

Just make sure that you you've verified yourself that what you did had the desired effect.
Randomly trying things is just as likely to break the submission test and make it pass you that way.
(Excuse my scepticism, you did go very quickly from no clue to getting that badge)

If you convinced yourself that you got it right, then you did, but if you suddenly got passed for no better reason than before, then you probably just broke it.