Possible mixed indentation in Python?

后端 未结 2 1857
被撕碎了的回忆
被撕碎了的回忆 2021-01-20 23:56

Looking at this question, I tried OP\'s the code on my machine. Here are a text version and a screenshot:

\"bad

2条回答
  •  滥情空心
    2021-01-21 00:31

    Easy!

    def square(x):
        runningtotal = 0
        for counter in range(x):
            runningtotal = runningtotal + x
    return runningtotal
    

    First, tabs are replaced (from left to right) by one to eight spaces such that the total number of characters up to and including the replacement is a multiple of eight <...>

    So this tab at the last line is replace with 8 spaces and it gets into the loop.

提交回复
热议问题