Given a Python program, task is to find the number of local variables present in a function.
Input : a = 1 b = 2.1 str = 'GeeksForGeeks' Output : 3
We can use the
co_nlocals() function which returns the number of local variables used by the function to get the desired result.
- Global and Local Variables in Python
- Python | Find the Number Occurring Odd Number of Times using Lambda expression and reduce function
- Python map function to find row with maximum number of 1's
- Python Program to Find the Number Occurring Odd Number of Times
- Python Program for Find sum of odd factors of a number
- Python Program for Find sum of even factors of a number
- Python program to find number of days between two given dates
- Python Program for Find minimum sum of factors of number
- Python program to find smallest number in a list
- Python program to find second largest number in a list
- Python program to find largest number in a list
- Python Program for Find largest prime factor of a number
- Python Variables
- Private Variables in Python
- Class or Static Variables in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.