I need to check variables looking like this:
if name1 != "":
(do something)
Where the number right after "name" is incremented between 1 and 10.
Do I need to write the test ten times or is there a way (without using an array or a dict) to "concatenate", so to speak, variable names?
I'm thinking about something like this:
for i in range(10):
if "name" + str(i) != "":
(do something)
Edit: I can't use a list because I'm actually trying to parse results from a Flask WTF form, where results are retrieved like this:
print(form.name1.data)
print(form.name2.data)
print(form.name3.data)
etc.
evalto do something like this means you have a terrible software design issue.form.name1,form.name2etc. and you can't modify the code (e.g. to makeform.namebe a list of those values), the appropriate tool isgetattr. I have added an appropriate duplicate. In general, use a list or dictionary to avoid the problem.