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.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course