Answer to Question #228029 in Python for kaavya

Question #228029

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




1
Expert's answer
2021-08-20T18:01:02-0400
def func(n):
  n = str(n)
  print(int(n[0]))
  print(int(n[-1]))
func(1456)

1
6

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS