-4

I wanna create differently Label name in Tkinter. For example..

import tkinter

root = tkinter.tk()
for i in range(1,10)
    "{}{}".format("Name", i) = tkinter.Label(root, text = i)
    "{}{}".format("Name", i).pack

I know "format" is not right instructions. But I already search many page to find solution...

Aiden.C
  • 1
  • 2

1 Answers1

1

You could use a dictionary for what you want:

d = {}
for i in range(1,10):
    d["{}{}".format('text', i)] = i

{'text1': 1,
 'text2': 2,
 'text3': 3,
 'text4': 4,
 'text5': 5,
 'text6': 6,
 'text7': 7,
 'text8': 8,
 'text9': 9}
yatu
  • 86,083
  • 12
  • 84
  • 139
  • I am sorry my friend. Is my question let you misunderstand. I'm sorry :( . But thank you for your help. :) – Aiden.C Jan 08 '19 at 14:07