Python string assignment error occurs on second loop, but not first
<p>The first run-through of the while loop goes fine:</p>

<pre><code>hour_count = list('00/')
hours = 0

while hours &lt; 24:                    #loop while hours &lt; 24

    hour_count[1] = hours            #&lt;- error occurs on this line
    hour_count = ''.join(hour_count) #convert to string
    ...
    hours += 1
</code></pre>

<p>However, upon the second loop, it gives a TypeError: 'str' object does not support item assignment. The purpose is to set a file path.</p>

<p>When you run this line <code>hour_count = ''.join(hour_count)</code>, you're changing the data type of <code>hour_count</code> from a list to a string.</p>

<p>Because strings are immutable, you can't modify one character via the index notation (the line before this line attempts to do that).</p>

<p>I'm not totally sure what your goal is, but perhaps you're looking to append to the list.  These docs will help with that.</p>

<p><a href="https://docs.python.org/3.4/tutorial/datastructures.html" rel="nofollow">https://docs.python.org/3.4/tutorial/datastructures.html</a></p>

python python-3.x typeerror