First digit in product of an array of numbers | Python implementation to find first digit of a single number ; Keep dividing by 10 until it is greater than equal to 10 ; driver function
def firstDigit ( x ) : NEW_LINE INDENT while ( x >= 10 ) : NEW_LINE INDENT x = x // 10 NEW_LINE DEDENT return x NEW_LINE DEDENT print ( firstDigit ( 12345 ) ) NEW_LINE print ( firstDigit ( 5432 ) ) NEW_LINE