string in range is not working
<p>I'm new to Python. I'm struggling with range. I'm not good at explaining this problem but I will show you a problem.</p>

<p>Here my code:</p>

<pre><code>my_hanes = ['Blue', 'Red', 'Grey', 'Black']
my_hanes_len = len(my_hanes)
for h in range(0, my_hanes_len):
   print(my_hanes_len[h])
</code></pre>

<p>Every time, the message pop up and said "'int' object is not subscriptable"</p>

<p>How do you solve this problem?</p>

<p>Thank you!</p>

<p>The problem with your code is that my_hanes is an array of strings.  So len(my_hanes) is an integer value (4) indicating the length of your array (aka python list).  If you want to get the length of each element of my_hanes as a list, you can iterate to make one:</p>

<pre><code>my_hanes = ['Blue', 'Red', 'Grey', 'Black']
my_hanes_len = list()
for hanes in my_hanes:
    my_hanes_len.append(len(hanes))
print(my_hanes_len)
</code></pre>

python int range