PyCharm EDU | Checker's error: infinite loop while revising student's code
已回答
Lesson 7 task 3:
- correct solution that doesn't cause endless loop
def fib(n):
result = []
a = 1
b = 1 # first editable field
while a < n:
result.append(a)
tmp_var = b
b = a + b # second editable field
a = tmp_var # third editable field
return result
print(fib(10))
# output: [1, 1, 2, 3, 5, 8]
- another correct solution that cases endless loop and RAM overloading
def fib(n):
result = []
a = 1
b = 0 # first editable field
while a < n:
result.append(a)
tmp_var = b
b = a # second editable field
a += tmp_var # third editable field
return result
print(fib(10))
# output: [1, 1, 2, 3, 5, 8]
What is wrong with it?
I am intensely interested to know! Do you have any idea?
请先登录再写评论。

Hello,
Thanks for the information! I reported an issue on YouTrack: https://youtrack.jetbrains.com/issue/EDU-1355