0

How to print first and last numbers in given 4 numbers using python

29th Dec 2021, 12:04 PM
Khadar Basha
Khadar Basha - avatar
3 Answers
+ 5
Khadar Basha , as you can see in the given answers, your information should be more precise. it would be the best to give us an input sample and also the resulting outputs. thanks!
29th Dec 2021, 3:32 PM
Lothar
Lothar - avatar
+ 1
please use some proper tags related to specific language and give some more information about your problem. #python num=123456789 num=str(num) print(f"first four : {num[:5]}\nLast Four : {num[-4:]} ") #output : first four : 1234 Last Four : 6789 Edit : num=int(input()) print(f"{str(num)[0]}{str(num)[-1]}") #input : 1234 #output : 14
29th Dec 2021, 12:37 PM
Ratnapal Shende
Ratnapal Shende - avatar
0
Input 1234 Output 14
30th Dec 2021, 7:54 AM
Khadar Basha
Khadar Basha - avatar