0

So yeah, i figured out how to write program that will print digits in reverse(with small help of the internet, put i get it). Anyway i want to write program that will print digits in their regular order.

def num_digits(n):
    count=0
    while count <= abs(n):
        count = count + 1
        n= abs(n)/10
        return count
    
def print_digits(n):
    while n > 0:
        print n #my "plan" is to go with n/ (10**num_digits(n)) and that taking
        #taking it like decimal with one decimal place and taking that value)
        #For example: 123 / (10**3) = 0,123. and than fix it so that is 0,1.
        #after this 0,1 * 10 = 1 and here is our 1st digit
        #how u guy understand how i want this to work
        #rest of code
        n=n/10
        print n #not quite sure for this line

help?
p.s. be gentle i'm learning yet

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by pyTony
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.