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

Code not running in task window. Runs well in Workspaces

Code not running in task window. Runs well in Workspaces for all kinds of iterables. Any one please help.Thank you.

slices.py
def first_4(items):
    slice1=items[0:4]
    return items

2 Answers

Istvan Nonn
Istvan Nonn
2,092 Points

Hi Suresh N, It is maybe late night or you are very tired, but you are not returning the right thing from the function.

Also in this case you don't need to introduce a new variable "slice1", you can simply just do:

return items[0:4]

Ah.. got it . Thank you for the help Istvan Nonn. I am still picking up the concepts :-). Thanks for the tips.