Help! IndentationError: unindent does not match any outer indication level

Asked 2 years ago, Updated 2 years ago, 64 views

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

2022-09-22 15:09

1 Answers

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


2022-09-22 15:09

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.