Counting number of characters in a key in a dictionary
<p>For homework I have been set the following:</p>

<p>Build a dictionary with the names from myEmployees list as
keys and assign each employee a salary of 10 000 (as value). Loop over the dictionary
and increase the salary of employees which names have more than four
letters with 1000 * length of their name. Print the dictionary contents before
and after the increase.</p>

<p>I can't figure out how to do it.</p>

<p>This is what I've come up with so far.</p>

<pre><code>employeeDict = {"John":'10,000', "Daren":"10,000", "Graham":"10,000", "Steve":"10,000", "Adren":"10,000"}

say = 'Before increase'
print say
print employeeDict

say1 = 'After increase'
print say1

for x in employeeDict:
x = len(employeeDict)
if x &gt; 5:
    print employeeDict[x]
</code></pre>

<p>First, change the values to integers/floats.</p>

<pre><code>employeeDict = {"John":10000, "Daren":10000, "Graham":10000, "Steve":10000, "Adren":10000}
</code></pre>

<p>After doing this, as you know, you need to loop over the items in the dict.</p>

<pre><code>for x in employeeDict:
    x = len(employeeDict)
    if x &gt; 5:
        print employeeDict[x]
</code></pre>

<p>In the code above, your "x" will be the employee name. And as you know, to asign a value to a key in dict, you have to use <code>dict[key] = value</code>, so try to do it in the <code>if x &gt; 5:</code> block statement. Im not trying to give you the full answer, but to push you in to the right direction.</p>

python dictionary count