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

Drew Bissonnette
Drew Bissonnette
309 Points

How to change a defined variable?

Almost done! Now, change "Treehouse" in greeting_list to the first item in your name_list variable.

Above is the task I need to complete, I'm not sure if I need to use a When or If statement. I've tried both and have gotten no where. Not sure if I even have to use either one.

Do I have to make a new variable to change an already defined variable?

greeting_list.py
full_name = 'Drew Bissonnette'
name_list = full_name.split()
hello = "Hi, I'm Treehouse"
greeting_list = hello.split()

3 Answers

Rachel Bird
Rachel Bird
11,968 Points

Yeah, this line wasn't necessary: hello = "Hi, I'm Treehouse". So best not to include.

Rachel Bird
Rachel Bird
11,968 Points

Hi Drew. I just wrote in the change. So:

full_name = "Rachel Bird"
name_list = full_name.split()
greeting_list = "Hi, I'm Rachel".split()
Drew Bissonnette
Drew Bissonnette
309 Points

Hey Rachel,

Thanks for your help! I also see I was adding in an extra step that was not needed with the way you did it. Is that ok, or is it something best not to do?

Mark Casavantes
PLUS
Mark Casavantes
Courses Plus Student 13,401 Points

I am not sure if this is your question Drew. I am maybe one step ahead of you and I am a rookie. I hope this is helpful. I do not know how to copy my code into this comment space.

greeting_list[2] = name_list[0]

name_list[0] has your first name in it and it is being placed in the third spot of greeting[2] list.