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 (Retired) Shopping List Lists and Strings

There seems to be an issue with Python Basics Challenge Task 4 of 4. Whenever I get to the final step it errors out

There seems to be an issue with Python Basics Challenge Task 4 of 4. Whenever I get to the final step it errors out. It says "Oops! It looks like Task 1 is no longer parsing. " I start over and it still just dies here. Help??

greeting_list.py
full_name = 'Ashley Elizabeth Knowles-Swingle'
name_list = full_name.split(' ')
greeting_list = "Hi, I'm Treehouse".split(' ')
greeting_list[len(greeting_list) - 1] = name_list[0]
greeting = greeting_list.split(' ')

1 Answer

Ryan Ruscett
Ryan Ruscett
23,309 Points

Holla,

Here is how the test work.

Task 1. Run test on task 1. Success. Task 2. Run test 1 AND 2 Success Task 3. Run test 1, 2, AND 3. Success Task 4. Run test 1 , 2, 3 AND 4 Fail - Test 1 is not passing. Tests stop and exit and tell you test 1 is no longer passing.

The reason TASK 1 is failing on TASK 4 is because your code is not compiling. You have a syntax error that keeps the code from compiling. Which means that when TASK 1 test 1 runs before it gets to TASK 2, 3 and 4. It fails. Since the code never compiled. So as far as the code is concerned. Task 1 is failing.

>>> greeting = greeting_list.split(' ')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'list' object has no attribute 'split'

See, list has no split() method. So the code is failing.

the KEY is JOIN. You need to JOIN it back into a string. You do this with .join.

ANSWER

full_name = 'Ashley Elizabeth Knowles-Swingle'
name_list = full_name.split(' ')
greeting_list = "Hi, I'm Treehouse".split(' ')
greeting_list[len(greeting_list) - 1] = name_list[0]
greeting = " ".join(greeting_list)

See, you say " " as this is where you want to join the words together. On spaces. Then .join will join the list back to a string on the spaces What list is that to join? The greeting_list.

See greetings is a a List indicated by the []. But after I join the string on the spaces with .join. You can see it returns greetings which is a string indicated by the ""

>>> greeting_list
['Hi,', "I'm", 'Ashley']
>>> greeting = " ".join(greeting_list)
>>> greeting
"Hi, I'm Ashley"
>>>

Does this help you, let me know and I can try a different approach.