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 trialPaul Feric
Courses Plus Student 724 Pointsshopping list help
i dont know how to get my "treehouse" to make it the first item on my name_list. i tried using append but that didnt work plz help did i use append wrong?>
full_name = "Paul Feric"
name_list = (full_name.split())
greeting_list = ("Hi, I'm Treehouse".split())
"Teehouse"append(name_list)
2 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsLet's walk through your code:
# Your name as a string
full_name = "Paul Feric"
# Your name as elements in a list
name_list = full_name.split() #<-- wrapping parens not needed
# A string split into a list
greeting_list = "Hi, I'm Treehouse".split() #<-- wrapping parens not needed
# Now, change "Treehouse" in greeting_list to the first item in your name_list variable.
# "Treehouse" is the 3rd item in "greeting_list" and can be referenced by greeting_list[2]
# Your first name can be referenced by name_list[0]
# replacing "Treehouse" with your name
greeting_list[2] = name_list[0]
Gordon Reeder
2,521 PointsIf you are trying to append 'treehouse' to name_list, the correct syntax is:
name_list.append('treehouse')
See, everything is Python is an object (you will learn about this later), and append is a method (built in function) of strings. So you specify the list you want to change. Call the method by using the dot notation. then pass the string you want to append as an argument to the append method.