I am currently stuck on this part of my guided project on “Finding Heavy Traffic Indicators on I-94” and seem not to be able to figure out the error.*
plt.figure(figsize = (10,5))
time_of_the_day = [daytime, nighttime]
for i, day in zip(range(1,3), time_of_the_day):
I noticed that when I run it without commenting on the line of .title(), it generates the error which is pointed out in the error message
However, when I do otherwise that is, comment on the aforementioned line, it runs without an error
Please can someone kindly explain this. Thank you in advance.
When you come across an error, one of the first things you should do is go to the documentation for the library that the code is from. In this case, the error is in the code using plt.title() so let’s go to the documentation: matplotlib.pyplot.title — Matplotlib 3.1.2 documentation.
If you read the documentation there, the first parameter that plt.title accepts is:
label : str
The “str” means that the parameter must be a string. Your code reads as follows:
My guess is that you wanted to write:
but it’s possible that the variable day is supposed to be a string and it isn’t, in which case you’ll want to go back to that variable and ensure nothing is going wrong there.
Best of luck!
Thank you very much for your response and clarity on this