Ad
  • Default User Avatar

    I do not understand why my code is returning an inccorect result. Below is an example of a test I failed.
    ('profit to return ', 41)
    ✘ 97 should equal 41

    My code is literally the print line --> print('profit to return ', profit) and then the return line "return(profit)"
    It goes from being 41 to 97, and this just happens again and again, why would python be mutating the value of profit with no code telling it to?

  • Default User Avatar

    I believe I was getting the same error, make sure you are only taking numbers into account in your method.

  • Default User Avatar

    Just want to clarify something that may be obvious to a lot of people, but I didn't find it obvious at all.

    I thought the item index method was supposed to also read in whatever was in the input ('a','b', etc.) and spit out the page number for that. I spent a long time trying to figure out why I was getting page numbers when I should have been getting -1 for any other input.

    It was an easy fix, I just removed that line of code and it worked - when I reviewed the instructions I realized only numbers were present in the function, but I think it could be added that only numbers need to evaluated.