Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Write a program to input a 6 digit number from the user, break and print the number in two digits seperately. Ex- 123456 12 34 56

It’s giving me wrong answer

a = int(input("Enter a 6 digit number: "))
if a > 99999 and a < 1000000:
    n1 = a % 100
    n2 = (a // 100) % 100
    n3 = (a // 100) // 10
    print(n1, n2, n3)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I think you meant to do

n3 = a // 10000

(which gives you 12 instead of 123 for an input of 123456), and then use

print(n3, n2, n1)

to get 12 34 56

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading