Legend position error

Screen Link:
https://app.dataquest.io/m/143/multiple-plots/11/final-tweaks

My Code:
I copied past your code under answer section written but it gives error

What actually happened:
I copied past your code under answer section written but it gives error

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’)

plt.show()

Replace this line with the output/error
TypeErrorTraceback (most recent call last)
in ()
7 label = str(1948 + i)
8 plt.plot(subset[‘MONTH’], subset[‘VALUE’], c=colors[i], label=label)
----> 9 plt.legend(loc=“upper left”)
10 plt.title (“Monthly Unemployment Trends, 1948-1952”)
11 plt.xlabel(“Month, Integer”)

TypeError: ‘str’ object is not callable```

hi @sirmayanik

Welcome to the DQ Community!

I tried the code that you have posted here, which as you said is the solution. It worked on my console. Instead of pasting a screenshot do you mind giving us your own code that gives you the error?

Please use the Preformatted text to not have the exact quotes used by in case there is a syntactical error, like as below:
image

fig = plt.figure(figsize=(10,6))
colors = ['red', 'blue', 'green', 'orange', 'black']

for i in range(5):
    # some code 

plt.show()