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 Basics (2015) Python Data Types Use .split() and .join()

John Brindle
John Brindle
2,516 Points

Why can't I get past task 3 in the beginner's python .join and .split task?

I keep getting an error that task one is no longer working even though I have passed through to task three. I don't seem to have altered anything yet I can't seem to get it right despite watching the video again!

any help would be gratefully accepted!

banana.py
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}.".format(display_menu = (", ").join(sundaes))

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The most common reason to get a "Task 1 is no longer passing" message is because you've introduced a syntax error in your code. At this point, none of the code can be compiled/interpreted. You can validate this in a workspace or on your local system. The error message here is "IndexError: tuple index out of range".

Now, this particular error likely doesn't mean much to you right now. You will need a little more Python under your belt before that means something. So I will try and put this as simply as I know how: you are trying to format a string with the result of assigning a value to a variable.

If you simply remove display_menu = from your code, it passes all three steps. We're wanting to format the string with the list that is created when we join the sundaes list with a comma and a space. You're doing that and then assigning it to display_menu. You have one of two choices here. You could set up the display_menu variable and assign it the value of the sundaes list properly joined and then format the string with display_menu or you can leave the extra variable out altogether and just format the string with the joined sundaes list, which is what will happen if you remove display_menu =.

Hope this helps! :sparkles:

John Brindle
John Brindle
2,516 Points

Hi Jennifer,

Thanks for that, I sat and had a play with the task again and separated out the steps, I was just curious to see if I could make it work on one line (as suggested in the task!) I can see now that I didn't need to assign the second variable! Seems obvious when somebody points it out to you!

Thank you!