I'm making a program that makes variables with a base name and variables like their id and series.
I use vars()[str(name+id+serie)] to make them and make it a button using the tkinter module.
When I launch it, it works until it tries to .get() the value from it, saying
keyError (variable name)
I tried to change how it's named, making it int() or moving the .get() here and there but nothing works.
# -*- coding: utf-8 -*
from tkinter import *
import math
import random
fenetre = Tk()
fenetre.geometry("1000x1000")
kanvas=Canvas(fenetre, width=500, height=500, bg="white")
id = 0
serie = 1
idcounter=0
while 1:
    print("serie =",serie)
    def cheezegrater():
        global serie,id,idcounter
        vars()[str("var_cheeze_sum"+str(serie))]=0
        for o in range(1,val+1):
            print("var11 =",var_cheeze_value11.get())
            vars()[str("var_cheeze_sum"+str(serie))] +=  vars()[str("var_cheeze_value"+str(id-val+o)+str(serie))].get()
        kanvas.pack()
        fenetre.mainloop()
    vars()[str("nombre_de_formes"+str(serie))] =int(float(input("combien?")))
    val = vars()[str("nombre_de_formes"+str(serie))]
    for o in range(1,val+1):
        id+=1
        vars()[str("var_cheeze_value"+str(id)+str(serie))] = Entry(kanvas, width=10)
        o+=1
        vars()[str("var_cheeze_value"+str(id)+str(serie))].pack
        kanvas.pack()
        fenetre.mainloop()
Traceback (most recent call last): File "C:\Users\Utilisateur\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__ return self.func(*args) File "C:/Users/Utilisateur/.PyCharmEdu2019.1/config/scratches/scratch_1.py", line 38, in cheezegrater vars()[str("var_cheeze_sum"+str(serie))] += vars()[str("var_cheeze_value"+str(id-val+o)+str(serie))].get() KeyError: 'var_cheeze_value11'
 
    