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()

Ryan Aston
Ryan Aston
1,069 Points

Task 3 help

When I check this it says 'It looks like Task 1 is no longer working' but I haven't changed the code for task 1. If you could explain to me what to do that would be great. Thanks for the help!

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

1 Answer

Torsten Lundahl
Torsten Lundahl
2,570 Points

First and foremost you are formatting 'menu' using the display_menu variable, before it has even been declared.

Python reads code in order from start to finish. This means it does not recognize 'display_menu' on line 3, since it is declared in line 4. In other words there is no variable called 'display_menu' before line 4.

Simply remove the format method on line 3 , and format 'menu' after the 'display_menu' has been declared instead.

The second problem is where you are using the join-method. You are using the method on a sequence instead of a string. It is supposed to be the other way around. Change it to ", ".join(sundaes) and it will work just fine.

Ryan Aston
Ryan Aston
1,069 Points

Thank you very much! I understand where I went wrong now.