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 Python Collections (2016, retired 2019) Slices Slice Functions

henry duquesnay
henry duquesnay
6,976 Points

Why does this not work!?!!?!

def first_4(1234567) return 1234567[0:4]

shouldn't this work? Why not? i've tried a million combinations and the only thing that works is when i write the word "iterable" in place of the number values

slices.py
def first_4(1234567)
    return 1234567[0:4]
Tom Finch
Tom Finch
1,248 Points

You will need a colon at the end of your first line.

1 Answer

Steven Parker
Steven Parker
229,005 Points

Tom's right about needing a colon, but another important syntax rule is that parameter names cannot be entirely digits. It doesn't have to be "iterable", almost any name will do; but it cannot start with a digit.