Results for “global”

8 results

  1. Challenge

    Launch counter crash

    record_launch() 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…

    Fix the code Medium 3 stages functions scope UnboundLocalError global
  2. Challenge

    Shadowed fuel

    …the function, creating a local variable and leaving the global fuel unchanged. Predict the last line, compare both values, fix it by returning the total, then write a function that uses only its…

    Fix the code Medium 3 stages functions scope local variables global variables
  3. Article Python Fundamentals

    Python Functions for Beginners

    …You'll find forum answers telling you to fix this with the global keyword. My advice is to skip that for now and do this instead: def burn(fuel, amount): return fuel - amount fuel = 100 fuel =…

  4. Article Python Fundamentals

    Variables and data types in Python

    …def for lambda try True del from nonlocal while and elif global not with as else if or yield break except import pass Example of valid variable names in space context: orbital_velocity = 7.8 #…