Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Collections (2016, retired 2019) Dictionaries Dictionary Basics

mattmilanowski
mattmilanowski
15,323 Points

Python Dictionary creation problem

Here is what it's asking in this challenge: Make a dictionary named player and add two keys to it. The first key should be "name" and the value can be any string you want.

The second key should be "remaining_lives". Set this key's value to 3

I create a dictionary like this: player = {'name': 'John', 'remaining_lives': '3'}

It keeps telling me remaining _lives isn't 3.

But it is! I think. What have I done wrong?

dicts.py
player = {'name': 'John', 'remaining_lives': '3'}

2 Answers

The challenge wants to to set remaining_lives to the integer three, not the string three.

Try this:

player = {'name': 'John', 'remaining_lives': 3}

I hope this helps :grin:

:dizzy: ~Alex :dizzy:

mattmilanowski
mattmilanowski
15,323 Points

I've only understood the concept of strings vs integers for 20 years. Apparently I still need more time! Thanks for the quick response.