小编Nor*_*orr的帖子

打印多个没有空格的对象

我正在编写一个基本程序来反转任何4位数字.

我知道我采取的是一种非常复杂的方法,但这正是我教授所要求的.到目前为止我有:

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

print(num1,num2,num3,num4)
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是print语句的输出给了我

x x x x
Run Code Online (Sandbox Code Playgroud)

当我愿意的时候

xxxx
Run Code Online (Sandbox Code Playgroud)

有什么建议?

python printing reverse spaces

1
推荐指数
1
解决办法
480
查看次数

标签 统计

printing ×1

python ×1

reverse ×1

spaces ×1