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 Technical Interview Prep: Python Basics Basic Python Splitsville

David Garcia
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
David Garcia
Python Development Techdegree Graduate 11,254 Points

I get the Error "Return the dictionary instead of printing it." I am returning the correct dictionary help.

split.py
# enter your code here
def splitsville(address):
    addy = (address.replace(",", " ").split())
    addy[0:4] = [" ".join(addy[0:4])]
    my_keys = ("street","city", "state", "zip_code")
    my_dict = dict(zip(my_keys, addy))
    return my_dict


addy = splitsville("100 E Main St, Anywhereville, Oregon, 22222")
print(addy)

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

Hey David Garcia, you are very close!

The print warning is a bit of false error. The checker has a general check whether any print statement exists. The error message incorrectly assumes the print is within the function. Quick fix is to the delete print statement.

Another error is the overly complicated creation of addy. The split can be completely in one step by splitting on ”, β€œ. The .replace is unnecessary. The join is also unnecessary. The rest is spot on.

Post back if you need more help. Good luck!!!

David Garcia
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
David Garcia
Python Development Techdegree Graduate 11,254 Points

Chris Freeman thanks Ill try it out when I get home! Not sure if you know but when do you think the job postings will be updated? I'm trying to leave my current job and get into a a dev job...

Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

I am not connected to the jobs posts so I can’t help there. Perhaps you could ask in the community general question category. Or email them at jobs@teamtreehouse.com!