Python program to print First Digit of a Number

# take input
num = int(input('Enter any Number: '))
# get the first digit
while (num >= 10):
    num = num // 10
# printing first digit of number
print('The first digit of number:', num)


Enter any Number: 123
The first digit of number: 1

Sharing Is Caring

Leave a Comment