Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Why won't my code work?

Attachment image

5 Answers

Relevance
  • keerok
    Lv 7
    2 years ago

    Something is wrong.

    Miss a letter, a semi-colon, a quote, or a curly bracket and your code goes haywire. Triple-check every line. If it doesn't work, you made a mistake. There is no other reason. Computers are that exact.

  • 2 years ago

    Try and debug it. We all can't be perfect first try.

  • Anonymous
    2 years ago

    Because it's the wrong one

  • 2 years ago

    You have the statement assigning dayofweek indented to be part of the while loop above it.  It doesn't belong there, and should be indented to the same level as the return statement below it. 

    You don't need the while loops at all, by the way.  Those are things you do in languages based on C, where % is a remainder operator.  Delete both while statements, keep the dayofweek variable, and change the return to:

        return dayofweek[e % 7]

    Don't try that in C/C++, Java or C# when e%7 can be negative if e<0; but it does the right thing in Python.

  • 2 years ago

    The first while condition does not assign dayofweek.  That condition checks True and then the code goes to return dayofweek

Still have questions? Get your answers by asking now.