Write a Python program to read three numbers and print them in ascending order.

Hello Guys in this article I will show you how to write a Python program to read three numbers and print them in ascending order

n=int(input("Please enter any three numbers"))
while(n!=1):
    r=n%10#123
    q=n//10
    d=r#3
    r1=q%10#2
    q1=q//10#1
    if (d>=r1) and (d>=q1):
        if(r1>=q1):
            print(q1,r1,d)
            break
        if(r1<=q1):
            print(r1,q1,d)
            break
    elif(q1>=d) and(q1>=r1):
        if (d>=r1):
            print(r1,d,q1)
            break
        if(r1>=d):
            print(d,r1,q1)
            break
    elif(r1>=d) and (r1>=q1):
        if(d>=q1):
            print(q1,d,r1)
            break
        if(q1>=d):
            print(d,q1,r1)
            break
    else:
        print("invalid input")
        break

Output

Please enter any three numbers987
7 8 9

With the help of this, you can write a Python program to read three numbers and print them in ascending order.

Thank you