Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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]