When I click the button, the time doesn’t change in the label. I don’t know why

  Kiến thức lập trình

My program is to display the timer in a set local time using tkinter and then changing the local time via a button to get a new timer with the newly set local time. But When I click the button it doesn’t do anything. I tried to print the ‘i ‘ value in the loop but it is always showing 2 only, which is last in range. pls help

`

import datetime as dt
import time
import pytz
from tkinter import *

tk = Tk()
tk.maxsize(500,500)

zones = ['Asia/Kolkata', 'Asia/Singapore', 'US/Eastern']
zone_nms = ['India', 'Singapore', 'USA']
p = 0

def clock(i):
   p = i
   print(i)
   txyt.configure(text=f'{dt.datetime.now(tz= pytz.timezone(zones[p])).strftime("%H:%M:%S")}')
   print(zone_nms[p])
   txyt.after(500, clock, i)

txyt= Label(tk, text=f'{dt.datetime.now(tz= pytz.timezone(zones[p])).strftime("%H:%M:%S")}')
clock(p)
#a = input('ENTER NO: ')
txyt.pack(anchor='center',padx=100, pady=100)


for i in range(3):
     Button(tk, command= lambda: clock(i) , text=f'{zone_nms[i]}').pack()

tk.mainloop()

`

LEAVE A COMMENT