Decode School

First digit of number in python

Python program to get input num and display the first digit of number num

Sample Input 1:

675

Sample Output 1:

6

Program or Solution

					    
							
n=int(input("Enter n value:"))
while(n>10):
    n=n//10
print(n)
    

					    
					

Program Explanation

Given number is continuously divided by 10, till it becomes lesser than 10 and greater than 0. and the final answer is first digit of given number.