Q:

Value not updated by function

I want to print the number of times a button was clicked but it always show the button is clicked 0 times. 
Tried googling but did not find any solution.
Code:
from tkinter import *
count = 0

root = Tk()
def clicked(count):

    print("the button is clicked "+ str(count) +" times")
    count+= 1

b = Button(root, text = "click here", command =lambda : clicked(count))
b.pack(fill=X)
root.mainloop()

A:

You must declare count as global.
from tkinter import *
count = 0

root = Tk()
def clicked():
    global count  # Here you will modify the variable count
    print("the button is clicked "+ str(count) +" times")
    count+= 1

b = Button(root, text = "click here", command =lambda : clicked())
b.pack(fill=X)
root.mainloop()

