我有一段简单的代码,我不明白我的错误来自哪里。解析器在第 5 行(if 语句)上用意外的缩进向我咆哮。有人看到这里的问题吗?我不。
def gen_fibs():
a, b = 0, 1
while True:
a, b = b, a + b
if len(str(a)) == 1000:
return a
If you just copy+pasted your code, then you used a tab on the line with the if
statement. Python interprets a tab as 8 spaces and not 4. Don't ever use tabs with python1 :)
1 Or at least don't ever use tabs and spaces mixed. It's highly advisable to use 4 spaces for consistency with the rest of the python universe.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)