很抱歉问这么基本的事情......
我已经制作了这个factorial.py
文件:
# Find the factorial of a number
def fact(n):
p = 1
for i in range(1, n+1):
p = p*i
return p
if __name__ == '__main__':
n = int(input('Enter an integer to find the factorial of: '))
f = fact(n)
print('Factorial of {0}: {1}'.format(n, f))
并保存在C:\Users\usersname
然后在新idle
我写了from factorial import fact
,
但它导致了如下图所示的错误: