i am using globals() and locals() to view the variables in the global and local space. however i am able to add variables to the global space using globals() but not able to add local variables using locals().
x=10
def show():
y=20
locals()['k']=40
print(locals()['k'])
print("k=",k)# generates error
show()
print(globals())
globals()['newkey']=77
print(globals())
print("newkey=",newkey)# shows error in editor typing but runs properly
how can we add local variable using locals