Answers for "how to take first digit of number python"

1

how to take first digit of number python

>>> number = 1520
>>> int(str(number)[:2])
15
Posted by: Guest on June-02-2021
0

how to take first digit of number python

import math

def first_n_digits(num, n):
    return num // 10 ** (int(math.log(num, 10)) - n + 1)
Posted by: Guest on June-02-2021

Code answers related to "how to take first digit of number python"

Python Answers by Framework

Browse Popular Code Answers by Language