Norr Norr - 1 year ago 80
Python Question

Printing multiple objects without spaces

I'm writing a basic program to convert any 4 digit number in reverse.

I know I'm taking a very complex approach, but that's what my professor requires. So far I've got:

print("This program will display any 4-digit integer in reverse order")

userNum = eval(input("Enter any 4-digit integer: "))

num1 = userNum % 10

userNum2 = userNum // 10

num2 = userNum2 % 10

userNum3 = userNum // 100

num3 = userNum3 % 10

userNum4 = userNum // 1000

num4 = userNum4 % 10


The issue I'm having is the output from the print statement gives me

x x x x

When I would prefer to have


Any advice?

Answer Source

If you read the description of the print(), you can see that you can change your last line for:

print(num1,num2,num3,num4, sep='')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download