I'm trying to rearrange the following array of strings:
myString =['000', ['1', 'two', 'three'], ['1', 'b', 'c']]
So that myString2 looks like
myString2 = [['000', '1', 'two', 'three'], [['000', '1', 'b', 'c']]
Looking around for some ideas (e.g. here) I attempted the following loop:
myString2 = []
for i in range(0,len(myString)-1):
myString2 [i].append(myString[0])
myString2 [i].append(myString[i])
But I get an error which I don't really understand :
IndexError: list index out of range
I'm fairly new to python and wonder if there is perhaps a simpler way than my current idea, and if not, if someone could kindly explain what is preventing the loop from running.
['000', ['1', 'two', 'three'], ['1', 'b', 'c'], '001'], and if so, what output do you expect?NameErrorbefore anything else as posted.