0

Hi I've been learning python through andrew harrington's guide, but i got stuck on a problem where you enter a list (ex. and have the IDLE return this----> 'veryhotday'.
Ive been thinking on how to do that using a for loop statement as was intstructed in the guide.

I know this may sound dumb but I guess I really need to see a sample code to do it. Thanks!

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by sneekula
0

Hi I've been learning python through andrew harrington's guide, but i got stuck on a problem where you enter a list (ex. and have the IDLE return this----> 'veryhotday'.
Ive been thinking on how to do that using a for loop statement as was intstructed in the guide.

I know this may sound dumb but I guess I really need to see a sample code to do it. Thanks!

its not sounding dumb. Its about watching and learning from it.

try this

list =  ["very", "hot", "day"]
print "".join(list)
0

Just a note, don't use function names like list as variable names.

mylist =  ["very", "hot", "day"]
print "".join(mylist)  # veryhotday

# or use this, might be more descriptive for a beginner

# empty string
s = ""
for word in mylist:
    # concatenate words
    s += word

print s  # veryhotday
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.