1

I am doing something painfuly simple, and rather than looping over the list, and += everything, I was wondering if there was a "sleezier" way to do it.

Simple concept I have something like:

some_string_array = [ "s", "t", "a", "c", "k", " ", "o", "v", "e", "r", "f", "l", "o","w" ]
some_string = some_string_array.--sleezy built-in flatten--() 
print(some_string)

And the result would be simply stack overflow

I am sure it is painfuly simple, but I couldn't find a good way to search for this online.

Thanks.

asked Jan 12, 2011 at 16:12
2
  • IMO, the solution @Sven Marnach provided is elegant, rather than sleazy. Commented Jan 12, 2011 at 16:15
  • Agreed, I knew it was simple ;) I gotta wait my 4 mins, then i will accept. I also revised the question for you S. Lott Commented Jan 12, 2011 at 16:23

2 Answers 2

12

Just use

"".join(some_string_array)
answered Jan 12, 2011 at 16:13
Sign up to request clarification or add additional context in comments.

Comments

0

even more sleazier:

reduce(lambda a,b:a+b,some_string_array)

http://docs.python.org/library/functions.html#reduce

answered Jan 12, 2011 at 17:06

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.