---
title: "Discussion on \"nonlocal in Python 3\" | Hashnode"
description: "Discussion on \"nonlocal in Python 3\". #TIL about nonlocal in Python 3\nInner functions can access outer variables but can’t modify them by default\nHere’s a contrived simple example\ndef outer():\n    num = 0\n    def inner():\n        nonlocal num\n        num += 1\n    inner()\n\nIf you remove t..."
url: "https://hashnode.com/posts/nonlocal-in-python-3/68b0d0e4051114c0318d3d08"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [nonlocal in Python 3](https://fullchee.hashnode.dev/nonlocal-in-python-3?utm_source=hashnode&utm_medium=feed)

#TIL about nonlocal in Python 3 Inner functions can access outer variables but can’t modify them by default Here’s a contrived simple example def outer(): num = 0 def inner(): nonlocal num num += 1 inner() If you remove t...

Aug 28, 2025 · 1 min read · fullchee.hashnode.dev  
Read the article

-   [#python3](https://hashnode.com/tag/python3)
-   [#python](https://hashnode.com/tag/python)

## Written by

[Fullchee Zhang](https://hashnode.com/@Fullchee)

@Fullchee · Toronto, Canada

  
[View profile](https://hashnode.com/@Fullchee)

Full Stack Dev at Forma AI

React, Django and SQL developer at Forma.ai

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
