I'm not sure what the context of your code is, but this should work:
class Test(webapp.RequestHandler):
def get(self):
s = self.request.get('sentence')
try:
self.myList.append(s)
except NameError:
self.myList= [s]
htmlcode1 = HTML.table(self.myList)
This makes list
an instance variable so it'll stick around. The problem is that list
might not exist the first time we try to use it, so in this case we need to initialize it.
Actually, looking at this post, this might be cleaner code:
class Test(webapp.RequestHandler):
def get(self):
s = self.request.get('sentence')
if not hasattr(self, 'myList'):
self.myList = []
self.myList.append(s)
htmlcode1 = HTML.table(self.myList)
[Edit:]
The above isn't working for some reason, so try this:
class Test(webapp.RequestHandler):
myList = []
def get(self):
s = self.request.get('sentence')
self.myList.append(s)
htmlcode1 = HTML.table(self.myList)