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:
- Subtracting the rest of separating it by 10, for example, taking out the last digit.
- 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: ")) n=0 while num>0: a = num%10 num = num - a num = num/10 print(int(a),end="") n = n + 1 print(n)
Enter a number with multiple digit: 123456789 9876543219
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.