I have the lists below and I need to assign the strings from fruit list into stall list depending on their length.
fruit = ['an', 'king', 'be', 'brave']
stall = [[],[],[],[]]
So the result should be like this
stall = [[ ],['an', 'be'],[ ],['king', 'brave']]
I’ve tried so many ways and even attempted to create a new list to see where I am going wrong but not even this is populating anything. Can someone please point me where I am going wrong? I've never had to append to list of lists before.
i = 0
s = stall[i]
for j in fruit:
if(len(j)) == i+1:
s.append(j)
i += 1
print(stall)