You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fib5.py in Chapter 1 uses the variable name "next", which is a builtin name and is best avoided in Python. Although less readable, I suggest renaming the variables to something like this:
deffib5(n: int) ->int:
ifn==0: returnn# special caselst: int=0# initially set to fib(0)next: int=1# initially set to fib(1)for_inrange(1, n):
lst, nxt=nxt, lst+nxtreturnnxt
The text was updated successfully, but these errors were encountered:
Thanks for bringing this to my attention. I regret the shadowing of the next() function here. Since the print edition has already been finalized, and it's not harmful for this toy example, we will be leaving it as-is, so as to keep all versions of the text in sync.
fib5.py in Chapter 1 uses the variable name "next", which is a builtin name and is best avoided in Python. Although less readable, I suggest renaming the variables to something like this:
The text was updated successfully, but these errors were encountered: