I want to loop through the AB test results and add a 'texts' list to the dictionary.
The 'texts' list is always a pair of 4 values, resulting in a list with 8 or 12 values.
100 such lists will be generated.
texts = [
[
'A text',
'89',
'71%',
'10%',
'B text',
'110',
'50%',
'9%',
'C text',
'60'
'30%',
'4%'
],
[
'A text',
'89',
'71%',
'10%',
'B text',
'110',
'50%',
'9%',
]
]
dic = {
'title': '',
'trial': '',
'quality': '',
'ctr': ''
}
for ix in texts:
dic.update(title=ix)
My hand stopped at the thought of using the update method.
dic_list = [
{
'title': 'A text',
'trial': '89',
'quality': '71%',
'ctr': '10%',
}
{
'title': 'B text',
'trial': '110',
'quality': '50%',
'ctr': '9%',
}
]
How can I create the above dictionary list?