Answers for "how to get the leftmost digit of an int"

0

how to get the leftmost digit of an int

# get the first digit
def firstDigit(n) :
    while n >= 10:
        n = n / 10
	return int(n)
  
# get the last digit
def lastDigit(n) :
    return n % 10
Posted by: Guest on July-31-2021
0

how to get the leftmost digit of an int

# get the first digit
def firstDigit(n) :
    while n >= 10:
        n = n / 10
	return int(n)
  
# get the last digit
def lastDigit(n) :
    return n % 10
Posted by: Guest on July-31-2021

Code answers related to "how to get the leftmost digit of an int"

Python Answers by Framework

Browse Popular Code Answers by Language