Python program to concentrate and print digits in invert request of a number

Extricating digits in Python: Here, we will figure out how to concentrate and print the digits in turn around the request of a number in Python?

Here, we are going to utilize some numerical base while programming. The issue is, the point at which you ask a number from the client, the client would give a contribution as numerous digit number (considering the whole number as it were). So it is anything but difficult to discover the sort of number yet it is difficult to locate the number of digits in the number.

In this way, in the accompanying issue, we are going to utilize the numerical stunt of:

  1. Subtracting the rest of separating it by 10, for example, taking out the last digit.
  2. Splitting a whole number by 10 gives a number in PC programming (the above explanation is possibly obvious when the factors are introduced as int as it were).


    Input: 12345

    Output: 54321

Python code to extract and print digits of a number in reverse order:

num = int(input("Enter a number with multiple digit: "))
while num>0:
    a = num%10
    num = num - a
    num = num/10
    n = n + 1   


Enter a number with multiple digit: 123456789

Here we are first utilizing a circle with condition num>0, and the last digit of the number is taken out by utilizing basic % administrator from that point onward, the rest of is subtracted from the num. At that point, number num is diminished to its 1/tenth so the last digit can be shortened.

The cycle rehashes and prints the switch of the number num.

Leave a Comment

error: Alert: Content is protected!!