First & Last Digits
Given a four-digit number N as input. Write a program to print first and last digit of the number.
Input
The input is a four-digit number N.
Output
Print the first digit in the first line and the last digit in the second line.
Sample Input 1
1456
Sample Output 1
1
6
Sample Input 2
9821
Sample Output 2
9
1
def func(n):
n = str(n)
print(int(n[0]))
print(int(n[-1]))
func(1456)
1
6
Comments
Leave a comment