How to fix TypeError: 'float' object is not subscriptable and an .append that isn't working
<p>This is the module that will input a two-dimensional array containing employee names and their corresponding salaries. 
Here the program is only taking one input and moving on instead of adding more inputs until the user types in "*". How do I fix this?</p>

<pre><code>salary = []
names = []

def floatInput():
    done = False
    while not done:
        nameIn = input("Please enter the employee name or * to finish: ")
        salaryIn = input("Please enter the salary in thousands for " + nameIn + ": ")
        try:
            salaryIn = float(salaryIn)            
        except:
            print("Program was expecting a positive integer or floating point number!")
        if nameIn == "*":
           done = True
        else:
            salary.append(salaryIn)
            names.append(nameIn)
        return salary
        return names
</code></pre>

<p>Calling the float Input function</p>

<pre><code>floatInput()
</code></pre>

<p>here I use a for loop to print and iterate through the list of names and salaries.</p>

<pre><code>for i in range(len(names)):
    print(names[i] + ", " + str(salary[i]))
</code></pre>

<p>Here I find the mean of the salaries.</p>

<pre><code>def salaryMean():
    mean = sum(salary) / float(len(salary))
    print("The mean of the salaries is: " + str(mean))
    return mean
</code></pre>

<p>Calling the salary mean Function</p>

<pre><code>salaryMean()
</code></pre>

<p>here I convert the salary to thousands.</p>

<pre><code>for i in range(len(names)):
    salary = salary[i] * 1000
print(salary)
</code></pre>

<p>Here I display all emplpyees who earn within a range of $5,000 from the mean
This is where I am getting the </p>

<pre><code>"TypeError: 'float' object is not subscriptable" 
</code></pre>

<p>and it points to the line </p>

<pre><code>"if salary[x] &gt;= (mean - 5000) and salary[x] &lt;= (mean + 500):"
</code></pre>

<p>.... How do I fix this?</p>

<pre><code>def displayNames():
    done = False
    x = 0
    while not done:
        if done:
            break
        if salary[x] &gt;= (mean - 5000) and salary[x] &lt;= (mean + 5000):
            print(salary[x])
        x += 1
        if x &gt; len(salary):
            done = True
</code></pre>

<p>Calling the display name Function.</p>

<pre><code>displayNames()
</code></pre>