I have a value that creates a list with two values. I need to add it as a sublist to another list muptiple times.
I need the resulting list to look like this: [["a", 1], ["b", 2], ["c", 3], ["d", 4]]
So this:
Small_list = []
Big_list = []
for item in db[1:]:
Small_list.append(item)
for item2 in db[2:]:
Small_list.append(item2)
Big list.append()
print(Big_list)
Returns: [[], [], [], []]
But doing the .extend() method
Small_list = []
Big_list = []
for item in db[1:]:
Small_list.append(item)
for item2 in db[2:]:
Small_list.append(item2)
Big list.extend()
print(Big_list)
Returns: ["a", 1, "b", 2, "c", 3, "d", 4]
Why does this happen and how do I do it the right way?
Big_listas both theappendandextendlist methods require you to pass them values, which is not being done in either or your cases.dbcontains, so that your question is reproducible.