Hi, I’m french and i’m trying to do a site where you can calculate weighted averages
I’m trying to take each textbox values and put them into a list, but it says :
“NameError: name ‘lst’ is not defined at”
from ._anvil_designer import Form1Template
from anvil import *
class Form1(Form1Template):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
lst = []
# Any code you write here will run when the form opens.
def button_1_click(self, **event_args):
"""This method is called when the button is clicked"""
txt1 = float(self.text_box_1.text)
lst.append(txt1)
def button_2_click(self, **event_args):
"""This method is called when the button is clicked"""
txt2 = float(self.text_box_2.text)
lst.append(txt2)
def button_3_click(self, **event_args):
"""This method is called when the button is clicked"""
txt3 = float(self.text_box_3.text)
lst.append(txt3)
def button_4_click(self, **event_args):
"""This method is called when the button is clicked"""
s = 0
for i in lst:
s = s + i
alert(s//len(lst))
Could you please help me
Thanks