max() arg is empty error when joining strings
<p>I'm new to coding and I was trying to make a script that will join the tuples inside 'sl', which are a sequence of letters, into a new tuple called 's' with the items as strings. and then print out the longest string inside s.</p>

<p>this is the code I came up with (or short version). When I try to print the max item of 's' in this code, returns a </p>

<blockquote>
  <p>max() arg is empty</p>
</blockquote>

<p>error. </p>

<pre><code>sl = [['m','o','o','n'],['d','a','y'],['h','e','l','l','o']]
s = []

s = (''.join(i) for i in sl) # join the letters inside sl, put them into s

print(max(s, key=len)) # print longest string inside s
</code></pre>

<p>but I still can iterate throught s with:</p>

<pre><code>for i in s:
    print(i)
</code></pre>

<p>and will print the words inside s, joined</p>

<p>I suppose that (''.join(i) for i in sl) isnt properly joining them as strings. Is there a way that the words inside 's' are join as strings?</p>

<p>It works, just replace <code>()</code> with <code>[]</code></p>

<pre><code>sl = [['m','o','o','n'],['d','a','y'],['h','e','l','l','o']]

s = []

s = [''.join(i) for i in sl] 

print(s)

print(max(s, key=len)) 
</code></pre>

python join