Answer to Question #302306 in Python for reyad

Question #302306

Task 11

Write a Python program which takes a number and prints the digits from the unit place, then the tenth, then hundredth, etc. (Right to Left)

[Consider the input number to be an INTEGER. You are not allowed to use String indexing for solving this task]

Example: If the user gives 32768, then print 8, 6, 7, 2, 3


1
Expert's answer
2022-02-24T12:18:48-0500
num = int(input("Input number: "))
print('Output:')
while (num > 10):
    digit = num % 10  
    num = num // 10
    print(f'{digit}, ', end='')
digit = num % 10     #  last digit
print(f'{digit}') 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS