Use a variable as index in Tkinter Use a variable as index in Tkinter tkinter tkinter

Use a variable as index in Tkinter


You have 3 way string format with python

text.get("%d.0"%(i + 1), "%.end"%(i)) # 1 text.get("{0}.0".format(i), "{0}.end".format(i) ) # 2text.get(f"{i+1}.0", f"{i}.end") # 3 


With only this information is hard to say what the purpose of this, but directly answering your question you can use string interpolation python.org such as .format method:

for i in range(1, n):       a = text.get("{0}.0".format(i), "{0}.end".format(i) )       b = text.get("{0}.0".format(i + 1), "{0}.end".format(i + 1))