Difficult to understand its context with this fragment of code, but what it seems is that you just want to make a "replace" in the list according to the values of the variables VnomeValor, VcorValor, etc, is not it? at least by looking at the code you passed, that's what it looks like. By the way, I think you came from another language, I recommend you check out PEP8, the style guide for python encoding .
I developed a function that receives a list and a dictionary with the variables (in the pythonic style) that you have posted and makes replace in the list according to the value of the variable, as far as I understand, the value of the list will be changed to 1 if the value of the variable is equal to 1, then it looks like this:
def get_list(_data, _list1):
if _data['cor_valor']['value']==1:
_list1[ data['cor_valor']['pos'] ]
if data['cpf_valor']['value']==1:
_list1[data['cpf_valor']['pos']]=1
if data['mail_valor']['value']==1:
_list1[data['mail_valor']['pos']]=1
if data['nome_valor']['value']==1:
_list1[data['nome_valor']['pos']]=1
return _list1
data = {'cor_valor': {'pos': 1, 'value': 0},
'cpf_valor': {'pos': 2, 'value': 1},
'mail_valor': {'pos': 3, 'value': 0},
'nome_valor': {'pos': 0, 'value': 1}
}
list1 = [0,0,0,0]
list1 = get_list(data, list1)
print (list1)
[1, 0, 1, 0]
See the code working here.
After a couple of hours I posted the above solution, I returned and saw how verbal it was, so I decided to reduce it, see:
data = {'cor_valor': {'pos': 1, 'value': 0},
'cpf_valor': {'pos': 2, 'value': 1},
'mail_valor': {'pos': 3, 'value': 0},
'nome_valor': {'pos': 0, 'value': 1}
}
list0 = [0,0,0,0]
def get_list_v2(_data, _list1):
for d in _data:
if _data[d]['value']==1:
_list1[data[d]['pos']]=1
return _list1
list1 = get_list_v2(data, list0)
print (list1)
View this new code here.