Watch out I am a beginner.
My question is: can I ask Python to attribut a different variable to each element of a list.
I created one list of questions and one list of answer
lst_questions = ['6+11', '3+3', '9+10', '2+7', '11+8', '9+3', '11+9', '3+3', '2+4', '7+4', '4+8', '3+9']
lst_reponses = [17, 6, 19, 9, 19, 12, 20, 6, 6, 11, 12, 12]
var1 = 0
var2 = 0
var3 = 0
var4 = 0
var5 = 0
var6 = 0
var7 = 0
var8 = 0
var9 = 0
var10 = 0
var11 = 0
var12 = 0
a = 0
b = 0
c = 0
d = 0
e = 0
f = 0
g = 0
h = 0
i = 0
j = 0
k = 0
l = 0
And I want to have:
def apply_solution(lst):
a = lst.index(var1)
b = lst.index(var2)
c = lst.index(var3)
d = lst.index(var4)
e = lst.index(var5)
f = lst.index(var6)
g = lst.index(var7)
h = lst.index(var8)
i = lst.index(var9)
j = lst.index(var10)
k = lst.index(var11)
l = lst.index(var12)
#Solution
lst[a], lst[b], lst[c], lst[d], lst[e], lst[f], lst[g], lst[h], lst[i], lst[j], lst[k], lst[l] = lst[a], lst[k], lst[j], lst[i], lst[h], lst[g], lst[f], lst[e], lst[d], lst[c], lst[b], lst[l]
#Verification indice
#print a,b,c
return lst
print apply_solution(lst_reponses)
Obviously, I receive error:
a = lst.index(var1)
ValueError: 0 is not in list
How can I attribute each element of lst_reponses to var1 ... var12 I hope I make myself clear.