Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Extract Digits from Number
00:00
5 left

Extract Digits from Number

EasyPython

Problem

Given the input 123, how would you get 1, 2, and 3 separately?

Implement the function below to return the integer's decimal digits from left to right. Use arithmetic operations rather than converting the number to a string.

Input: A non-negative integer number.

Output: A list containing its digits in left-to-right order.

Constraints

  • 0 <= number <= 10^9
  • Return the digits from left to right
  • Do not convert the number to a string

Function Signature

def separate_digits(number):
Interviewer

Your question is Extract Digits from Number. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.