I have a list :
main = ['A','B','Bb','Ab','Ac','Bc','C','D']
I want to replace these following values in list main with the values provided here:
'A' - 23
'Ab' - 345
'Ac' - 57
'B' - 56
'Bb' - 82
'Bc' - 89
and replace the other strings with zeros
So the desired output is
new_main = [23,56,82,345,57,89,0,0]
return [23,345,57]
orreturn [56,82,89]
would produce[23,56,82,345,57,89,0,0]
? Do you mean to return the next value of the respective list? – MisterMiyagi Jul 10 '20 at 16:47in
statement does, as well as what returning alist
does. From your input/output statements, I would suggest a lookup table, with either a dictionary or another construct. – sal Jul 10 '20 at 16:47main = ['Ac', 'A', 'Ab', 'Ad', 'Bd', 'Bc', 'Bb', 'B']
? – MisterMiyagi Jul 10 '20 at 16:58