In step 1 of Object Oriented python, Data Analysis course, the instruction 1 shows some weird behavior. If I didnt put a print statement for the last line, my output is different from the one that the solution expect. without print, the type function didnt return the keyword “class”. wonder why is that.
But if I add print function to the last line of code it works fine.
how a print function can change the output of the code?
Interesting question! I’ve only been using python for a couple months, but I wonder if it has to do with the behavior of what is being used to run the code. In Jupyter Notebook I see the same thing. When I tried something similar with python from the command line, however, bothtype(d) and (print(type(d)) gave me an output of <class 'dict'>! I don’t really know how that works, but that would be my best guess at why you’re seeing a difference in the output.
thank you. I see the same thing. When I run the same code from Jupyter I am getting same output where as from python command line getting <Class ‘dict’>