Seems to be a simple question but I tried a dozen of possibilities without result.
I just want to change [‘55.00’, [‘CHF’, ‘0.00’]] into [[‘55.00’], [‘CHF’], [‘0.00’]]
or:
var1 = "55.00"
var2 = "CHF"
var3 = "0.00"
As an example, I tried:
mik = ['55.00', ['CHF', '0.00']]
mik = [s.split(',') for s in ','.join(mik).split(',')]
Result:[[‘C’], [‘H’], [‘F’], [‘ ‘], [‘0’], [‘.’], [‘0’], [‘0’]]
What could be the solution in my situation?
>Solution :
You can unpack your list. This answer assumes that you always have RHS of the format [el, [el2, el3]]
>>> var1, (var2, var3) = ['55.00', ['CHF', '0.00']]
>>> var1
'55.00'
>>> var2
'CHF'
>>> var3
'0.00'