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 Program to Find the Number Occurring Odd Number of Times
- Python Program for Find sum of even factors of a number
- Python Program for Find sum of odd factors of a number
- Python | Find the Number Occurring Odd Number of Times using Lambda expression and reduce function
- Python program to find largest number in a list
- Python program to find second largest number in a list
- Python program to find smallest number in a list
- Python program to find number of days between two given dates
- Python Program for Find minimum sum of factors of number
- Python Program for Find largest prime factor of a number
- Python map function to find row with maximum number of 1's
- Python Program for Program to find area of a circle
- Python Program for Efficient program to print all prime factors of a given number
- Python Program for Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +.......+ n/n!
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.