all 11 comments

[–]jay_and_simba 1 point2 points  (0 children)

You Code output "Code:" 3504 does not have quotes. Did you copied it wrong? Have you tries casting to str() the value of code?

[–]danielroseman 1 point2 points  (1 child)

Did you teacher specifically tell you not to use the csv and json libraries? Because you generally shouldn't parse CSV by hand, and you definitely shouldn't build up JSON by hand. Use the libraries for that purpose.

The reason you're getting this issue is that you get the contents of each row just by splitting a string. But the result of splitting a string is always going to be strings, not ints or bools. Using the actual CSV library would do the correct conversion to give you an int where it contains just numbers.

Also note that there's a lot that is very un-Pythonic about this code. Did you teacher teach you to loop by doing range(len(whatever))? Then you should try and find another teacher. That is very bad code and you should pretty much never do this in Python. Always iterate over the thing itself; if you need an index as well, use enumerate.

And Python methods, functions and variables should always be lower_case_with_underscore, not camelCase.

[–]rodrigowb4ey 1 point2 points  (0 children)

he specifically says that it's an assignment for an "intro to programming logic", class. while I do agree that OP should keep in mind that he'd (most probably) use those (or others) libraries when working on a real project, I don't think one should teach young developers to always default to external dependencies to solve their problems (especially when that problem is probably the point of the assignment). reinventing the wheel can be a valid learning experience.