This code is letting me input a string, and that string is added to the dict 'd'. However I want to use this functionality in a gui but when used with the gui I am missing something. Because it won′t work.
This first code works as intended (being outside a function)(Print statements are there just for the testing purpose.):
d = {"username": "XYZ", "email": "xyz@gmail.com", "location":"Mumbai"}
r=str(input())
d[r] =' '
print(r)
print(d)
While this code below does not work as intended. When I run the code it just idles. Why?
How do I fix this global/local issue (just my guess)?
def newSite():
print('opening dialogue')
r = str(input())
d[r] =' '
The function is called in a button.
Button(root, height=1, width=10, text=" <- Input site! ", command=newSite).grid(row=6, column=3, sticky=W, pady=10)
question from:
https://stackoverflow.com/questions/66056800/inside-and-outside-function 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…