Practice
Integer Input Validation
2025/Feb/Mar
EASYLoops
Write an algorithm to allow a number to be input and check whether it is an integer.
If the number is an integer, the loop ends. If not, output "Please try again" and repeat until a valid integer is provided.
Input: A sequence of numbers.
Output: "Please try again" for each non-integer input.
Example:
Input: 4.5
3.14
7
Output: Please try again
Please try again
Premium is coming soon. All grading features are currently unlocked.
Sample Test Cases
Test 1: Two invalid then valid
Inputs: 4.5, 3.14, 7
Expected: Please try again
Please try again
Test 2: Valid on first try
Inputs: 10
Expected:
Ctrl+Enter
Press Ctrl+Enter to run your code
or Ctrl+Shift+Enter to grade