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

hubert chen
hubert chen
12,761 Points

lists and basics code challenge python

What's wrong with my code, I can't seem to figure it out.

greeting_list.py
full_name="Hubert Chen"
name_list=full_name.split( )
greeting_list=("Hi, I'm X".split( ))
greeting_list[2]=name_list
greeting=" ".join(greeting_list)

1 Answer

Juan Martin
Juan Martin
14,335 Points

Hello my friend.

You're assigning all the name_list to greeting_list[2], the challenge states that you must assign "the first item in your name_list", so it must be name_list[0]. Here's how it should look:

full_name = "Hubert Chen"
name_list = full_name.split( )
greeting_list = "Hi, I'm X".split( )
greeting_list[2] = name_list[0] # I've changed name_list to name_list[0]
greeting = " ".join(greeting_list)

Hope this helps :)

hubert chen
hubert chen
12,761 Points

Thanks alot...been stuck for a while

Juan Martin
Juan Martin
14,335 Points

No problem my friend, I'm glad I could help you :)