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
Nix
58.9k31 gold badges154 silver badges206 bronze badges
-
IMO, the solution @Sven Marnach provided is elegant, rather than sleazy.GreenMatt– GreenMatt2011年01月12日 16:15:44 +00:00Commented 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. LottNix– Nix2011年01月12日 16:23:10 +00:00Commented Jan 12, 2011 at 16:23
2 Answers 2
Just use
"".join(some_string_array)
answered Jan 12, 2011 at 16:13
Sven Marnach
608k123 gold badges969 silver badges866 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
even more sleazier:
reduce(lambda a,b:a+b,some_string_array)
answered Jan 12, 2011 at 17:06
Frost.baka
8,0412 gold badges24 silver badges18 bronze badges
Comments
lang-py