Digit Extractor - Problem
Given a 4-digit number, extract and print each digit separately on a new line.
For example, if the input is 1234, the output should be:
1 2 3 4
Each digit should be printed on its own line, starting from the leftmost (thousands place) to the rightmost (units place).
Input & Output
Example 1 — Basic 4-digit number
$
Input:
number = 1234
›
Output:
1
2
3
4
💡 Note:
Extract each digit: thousands=1, hundreds=2, tens=3, units=4. Print each on a new line.
Example 2 — Number with zeros
$
Input:
number = 5067
›
Output:
5
0
6
7
💡 Note:
Even with zero in hundreds place, each digit is extracted: 5, 0, 6, 7.
Example 3 — All same digits
$
Input:
number = 7777
›
Output:
7
7
7
7
💡 Note:
When all digits are the same, each position still outputs the same digit.
Constraints
- 1000 ≤ number ≤ 9999
- The input is guaranteed to be a 4-digit integer
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code