I have a list of items in python something like this:
input:
a=['nt','mt','pt']
I want to make each item in the above list as a variable and then assign that variable to a regex involving that variable.
output:
I want something like this:
nt=re.compile("%s=[a-z]+&" %nt)
mt=re.compile("%s=[a-z]+&" %mt)
pt=re.compile("%s=[a-z]+&" %pt)
how do i go about doing this ???
Thanks.
[sorry didn’t pose the question in the best way possible ]
Keep data out of your variable names. Don’t use variables, use a dictionary: