【发布时间】:2021-03-21 15:21:32
【问题描述】:
我得到了一个使用循环编写程序的任务。用户输入一个 1-98 的数字,然后输出是该数字的阶乘。如果用户输入的数字不是上述数字,则要求用户重新输入适当的数字。现在当用户输入合适时,输出的输出与阶乘结果不匹配。
here's the picture of that error
这是代码
num = int(input("Input Number (1-98) : "))
Factorial = 1
for a in range(1,num+1):
if 0 < num < 99:
Factorial = Factorial*a
else :
print("input does not match, Repeat input (1-98)")
num = int(input("Input Number (1-98) :"))
print ("The factorial of", num, "is", Factorial)
你能帮我解决这个问题吗?
【问题讨论】:
-
请不要张贴文字图片,无论是代码、控制台输出还是错误消息。请在发布之前浏览您自己的程序并尝试对其进行调试。
标签: python loops for-loop output factorial