logo CodeStepByStep logo


Language/Type: Python errors % return

Consider the following function, which is written incorrectly. Under what cases will the function print the correct answer, and when will it print an incorrect answer? What should be changed to fix the code? (For an extra challenge, can you think of a way to write the code correctly without any if/else statements?)

Function: Write a Python function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.