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

I am struggling with code and I'm not sure what I am doing wrong. I've tried a few codes but nothing seems to be working

I am getting a syntax error for the : in between the key and the values. Please could you help me with this task.

split.py
def splitsville_dict = {'street' : '100 E Main St', 'city' : 'Anywhereville', 'state' : 'Oregon', 'zip_code' : '22222'}
return ("address", str(splitsville.dict))

1 Answer

Megan Amendola
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Megan Amendola
Treehouse Teacher

Hi! First, you need to create a function called splitsville that takes an address parameter. You have the start of your function, but it should look something like this:

def splitsville(address):
# code

The address being passed into your function will look like the example: '100 E Main St, Anywhereville, Oregon, 22222'

Inside of the function, you need to take this address and split it up into its parts using .split(). Resource

# split example
>>> "I love Dogs".split(" ")
["I", "love", "Dogs"]
>>> "Cheese, Tatertots, Milk".split(", ")
["Cheese", "Tatertots", "Milk"]

Then turn those parts into a dictionary and return it. Resource