Skip to content

Bp #1130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Bp #1130

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
13th challenge completed
  • Loading branch information
BaoPham92 committed Feb 11, 2020
commit 585af1ed27b44c4bd93f494c4ce816f6d2f33587
6 changes: 6 additions & 0 deletions src/12_scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
# Good reading: https://www.programiz.com/python-programming/global-local-nonlocal-variables

# When you use a variable in a function, it's local in scope to the function.

# * SOLUTIONS BELOW:
# * OPEN INTERPRETER && RUN: python3 12_scopes.py

x = 12

def change_x():
global x
x = 99

change_x()
Expand All @@ -19,6 +24,7 @@ def outer():
y = 120

def inner():
nonlocal y
y = 999

inner()
Expand Down