+ 1

how to print given numbers of digits from a number?(like below)

suppose, n= 2 Number = int(input()) #4578 therefore, i want to print : 78 if n =3 then, print: 578

24th May 2018, 8:15 PM
Tincture
4 ответов
24th May 2018, 9:43 PM
Markus Kaleton
Markus Kaleton - avatar
+ 1
number = [i for i in input()] n = int(input()) print(*number[len(number)-n:])
24th May 2018, 8:29 PM
davy hermans
davy hermans - avatar
+ 1
n = int(input("Enter number of digits: ")) print(input("enter a number >= "+str(n)+" digits: ")[-n:])
25th May 2018, 12:23 AM
E_E Mopho
E_E Mopho - avatar
0
You could mod (%) the result by 10**n, which will mostly work, except for 0 which you can make another if branch for
24th May 2018, 8:22 PM
Dan Walker
Dan Walker - avatar