If I run this code, I get an error ㅜ 왜 Why?
import sys
def Factorial(n): # Return factorial
result = 0
for i in range (1,n):
result = result * i
print "factorial is ",result
return result
IndentationError: unindent does not match any outer indentation level
python indentation
Another problem is not like. Maybe in writing by tab and share space and an error occurs.
And I think the factional value will come out properly if the result = is set to 1, not 0.
import sys
def Factorial(n): # return factorial
result = 1
for i in range (1,n):
result = result * i
print "factorial is ",result
return result
print Factorial(10)
PEP8 related article Which tab & space do you want indented in Python?Please look at
© 2024 OneMinuteCode. All rights reserved.