---
title: "What is a closure in Python?"  
description: "What is a closure in Python?"  
author: "Prakash nidhi Verma"  
published: 2018-07-19  
updated: 2020-09-19  
canonical: https://www.mindstick.com/interview/23474/what-is-a-closure-in-python  
category: "python"  
tags: ["python-3.4", "python"]  
reading_time: 1 minute  

---

# What is a closure in Python?

A closure is a event in python. its occur when a nested function doing references a value in its enclosing scope.The whole point here is that it remembers the value.

```
>>> def A(x):     def B():
        print(x)
    return B
>>> A(7)()
```

## Answers

### Answer by Prakash nidhi Verma

A closure is a event in python. its occur when a nested function doing references a value in its enclosing scope.The whole point here is that it remembers the value.

```
>>> def A(x):     def B():
        print(x)
    return B
>>> A(7)()
```


---

Original Source: https://www.mindstick.com/interview/23474/what-is-a-closure-in-python

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
