Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Challenge

Polliana Odeth de Melo Machado
seal-mask
.a{fill-rule:evenodd;}techdegree
Polliana Odeth de Melo Machado
Python Development Techdegree Student 1,741 Points

For in

If it was only one dictionary inside the list data, could I do this way? I mean, I need the "for in" bacause there is more than 1 dictionary or bacause the dictionary is inside of the list?

data = { "email": "we@afi.co", "name": "Warren Bates", "date_joined": "4/20/2048", "admin": "False", "id": "36" }

data['email'] = 'we@afi.co'

del(data['name'])

data['first_name'] = 'Warren Bates'.split(" ")[0]

data['last_name'] = 'Warren Bates'.split(" ")[1]

data['date_joined'] = '4/20/2048'

if data["admin"] == 'False': data["admin"] = False else: data['admin'] = True

data["id"] = int(36)

print(data)

1 Answer

Steven Parker
Steven Parker
218,692 Points

When posting code, always use Markdown formatting to preserve the code's appearance, particularly the indentation which is crucial in Python. You might want to take a look at this video about Posting a Question.

But the loop is used for processing a list of multiple items, the kind of items doesn't matter. If you know the data will be only one item, you wouldn't need a list; but in this exercise, the function needs to process a list.