TypeError: 'str' object is not callable

My Code:

    fig = plt.figure(figsize=(10,6))
    colors = ['red', 'blue', 'green', 'orange', 'black']
    for i in range(5):
        start_index = i*12
        end_index = (i+1)*12
        subset = unrate[start_index:end_index]
        label = str(1948 + i)
        plt.plot(subset['MONTH'], subset['VALUE'], c=colors[i], label=label)
    plt.legend(loc='upper left')
    plt.xlabel('Month, Integer')
    plt.ylabel('Unemployment Rate, Percent')
    plt.title('Monthly Unemployment Trends, 1948-1952')


What I expected to happen: After trying to get this to work I simply copied and pasted the solution, but it is still generating the following error message:

TypeErrorTraceback (most recent call last)
<ipython-input-1-819ca87954ef> in <module>()
      8     plt.plot(subset['MONTH'], subset['VALUE'], c=colors[i], label=label)
      9 plt.legend(loc='upper left')
---> 10 plt.xlabel('Month, Integer')
     11 plt.ylabel('Unemployment Rate, Percent')
     12 plt.title('Monthly Unemployment Trends, 1948-1952')

TypeError: 'str' object is not callable

Hello @f.echavarria521,

Read up on how to resolve this error here.

Happy learning!


Thank you, that worked :))