Challenge
Launch counter crash
…adds 1 to a global counter and stops with an UnboundLocalError. Predict it, find out why Python treats the name as local, fix it by passing the count in and returning the new one, then write a fuel…
3 results
Challenge
…adds 1 to a global counter and stops with an UnboundLocalError. Predict it, find out why Python treats the name as local, fix it by passing the count in and returning the new one, then write a fuel…
Quiz
…Why a list can be changed without global , and where UnboundLocalError comes from Blocks such as if and for , which have no scope of their own, and list comprehensions, which do Nested functions, the…
Article Python Fundamentals
…fuel = 100 def burn(amount): fuel = fuel - amount burn(30) UnboundLocalError: cannot access local variable 'fuel' where it is not associated with a value Because there's an assignment to fuel inside…