It's dangerous to go Alone


#1

What exactly is the mistake I'm making here?


#2

Hello @arraywhiz39529, did you look at the error on line 18 of your code? Look at inventory['gold'], since it holds 500, you can't assign 50 to it (as the error tells). You should reread instruction #5.


#3

Hey gamer,

Thanks for taking the time to reply me.

Strangely, I changed the value of gold inside inventory dictionary and it worked.

I'm still trying to figure out if I can update or add to existing values in a dictionary

Regards,
Drithin


#4

Hi Arraywhiz,
I think i've found a way to do it by doing

inventory['gold']=inventory['gold'] + 50

Although i'm sure I tried that an hour ago and it didn't accept it...

Anyway it seems to work now, hope it helps.

Hugo.


#6

That just worked for me.


#7

is it possible to make it like thins: inventory[‘gold’] += 50


#8

Yes it is.
I just tried it


#9

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