Shorthand to Increase a Variable's Value?

Why can’t I do

inventory['gold'] + 50

instead of

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

?

11 Likes

You can!

The shorthand for addition is +=

When I did this exercise inventory[‘gold’] += 50 worked like a charm.

Good luck!

16 Likes

That’s perfect! Thanks!

1 Like

This topic is solved.