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.
Noor Hafiza Binti Ibrahim11,616 Points
A typo? Any better ways to solve the code challenge?
All i get is: Bummer: Uh oh, I didn't get the correct value returned. It should have been '55555' for the zip. Instead,
# enter your code here def splitsville(address): address = address.split(",") keys = 'street', 'city', 'state', 'zip_code' address_dict = dict(zip(keys, address)) return address_dict
Jeff MudayTreehouse Moderator 26,896 Points
That is a clever solution. Good work!
Unfortunately, it does require stripping the parts of the extraneous spaces. There are quite a few ways to do this, I suggest a simple approach below. (alternatively, you could also use a "list comprehension" after the split.)
Good luck with your Python studies!
def splitsville(address): address = address.split(",") keys = 'street', 'city', 'state', 'zip_code' address_dict = dict(zip(keys, address)) for k, v in address_dict.items(): address_dict[k] = v.strip() return address_dict