Challenge 2: Count Iterations of a Loop Until a Condition

This challenge will test your knowledge of while loops.

We'll cover the following

Problem Statement

  • A variable x is provided to you.

  • Repeatedly decrease the value of the variable x by 3 each time, as long as x is greater than or equal to 0.

  • Print the number of times the iteration runs.




   iteration count

Sample Input


Sample Ouput


Coding Exercise

Write your code below. It is recommended​ that you try solving the exercise yourself before viewing the solution.

Note: There is a test function given in the code for testing purposes. Do not modify it.

Important Note: A mutable variable x is already provided to you. This has the desired value. You just have to write the while loop construct.

Good luck! 🤞