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

Jamie Evans
Jamie Evans
2,092 Points

Why isnt this working?

For some reason this is not giving me a pass? Even though I can clearly see that it is indeed changing greeting_list[3] with name_list[0]

Jamie Evans
Jamie Evans
2,092 Points

full_name = "Gordon Evans" name_list = full_name.split() sentance = "Hi, I'm a Treehouse" greeting_list = sentance.split() if greeting_list[3] == "treehouse": greeting_list[3] == name_list[1]

1 Answer

Jamie Evans
Jamie Evans
2,092 Points

ok, changed my code. I know i didnt need a if, but for fun:) full_name = 'Gordon Evans' name_list = full_name.split() greeting_list = "Hi, I'm a Treehouse".split() greeting_list[2] = name_list[0] works great, but I got the answer from another post. If someone could please explain why greeting_list[2] works instead of greeting_list[3]. I thought because I wanted to directly change item 3 in list, I would need to use [3]