TypeError: list indicies must be integers, not str
<pre><code>foo = ("PandaBears")
l = list(foo)
random.shuffle(l)
Output = ''.join(l)
print(Output)
</code></pre>

<p>I have been at this code for ages trying to figure out the problem but I have had no luck. A few hours before it was working perfectly with absolutely no trouble - <code>I haven't even changed / upgraded python either.</code> </p>

<p>The error is coming from </p>

<blockquote>
  <p>l = list(idf)  </p>
</blockquote>

<p>and I have tried using <code>[]</code> instead of <code>()</code>.  </p>

<p>Any improvements on this code would be appreciated</p>

<p>The parenthesis are useless here:</p>

<pre><code>foo = ("PandaBears")
</code></pre>

<p>Just write:</p>

<pre><code>foo = "PandaBears"  # str
</code></pre>

<p>If you want a singleton <code>tuple</code>, add a trailing comma:</p>

<pre><code>foo = ("PandaBears",)  # tuple
</code></pre>

<p>If <code>foo</code> is a string, the following statement construct a list of letters:</p>

<pre><code>l = list(foo)
</code></pre>

<p>Don't know what is <code>diff</code>. </p>

python list python-3.x