I'm using Jinja2 to generate a form with a variable number of inputs, labelled input_1, input_2, etc. Using Google App Engine (python), I'm then trying to access the values of these inputs in my request handler using self.request.args.get()
.
However, depending on the number of inputs generated by the form, the script needs to read multiple variables. The script knows how many there will be, so the question is just how to use some kind of variable variable in a for loop to read them all efficiently.
The kind of thing I'm after is conceptually like this:
for x in total_inputs:
list.append(input_x)
I could of course just use if statements for different numbers of inputs and do the variable names manually, but that seems awfully clunky - surely there is a better way?
Many thanks