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

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