+ 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
4 Respostas
+ 1
number = [i for i in input()]
n = int(input())
print(*number[len(number)-n:])
+ 1
n = int(input("Enter number of digits: "))
print(input("enter a number >= "+str(n)+" digits: ")[-n:])
0
You could mod (%) the result by 10**n, which will mostly work, except for 0 which you can make another if branch for