Home > OS >  Write a program to input a 6 digit number from the user, break and print the number in two digits se
Write a program to input a 6 digit number from the user, break and print the number in two digits se

Time:11-10

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)

CodePudding user response:

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

  • Related