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 trialdalraemurray
442 PointsStuck joining a list into a string and storing it in a new variable for greeting_list.py
Script so far but I don't know how to join this list back into a string and store it in the variable 'greeing', ending up w/ 'greeting' containing "Hi, I'm <your first name>".
full_name = "Dal Mister"
name_list = "Dal Mister".split()
print name_list
greeting_list = "Hi, I'm X".split()
print greeting_list
greeting_list.remove(greeting_list[2])
greeting_list.append(name_list[0])
for item in greeting_list:
print (item + " ")
2 Answers
Jegnesh Gehlot
5,452 PointsHi dalraemurray , In order to complete this problem you have to store the string in a new variable. According to your code you are printing the items on the screen one at a time. Here is the code
full_name = "Dal Mister"
name_list = "Dal Mister".split()
print name_list
greeting_list = "Hi, I'm X".split()
print greeting_list
greeting_list.remove(greeting_list[2])
greeting_list.append(name_list[0])
result='' " #creating a new variable
for item in greeting_list:
result=result+item+" " #storing the item in the result
print result #If the above logic is part of a function and you want to return the value then use "return result" instead of print result
Jegnesh Gehlot
5,452 PointsIt looks like USER ID with Staff and Moderator next to them can delete the thread. Here is a relevant thread:
Kenneth Love
Treehouse Guest TeacherWe typically don't delete posts, especially when they might be the same issue that someone else runs into.
dalraemurray
442 Pointsdalraemurray
442 PointsThanks! I actually figured it out right after posting this. Could't find a way to remove my post. Is there a way?