[Solved] how can i remove bracket in list with float data


Ah I see your problem.

this is really what i want to do. i want to add tt1 in another list but the thing is this just happen [0, [102, 0.5, 0.591, 0.529, 10, 42, 26, 6, 8, 17, 24], 1, 27, 109, 0.41100000000000003, 0.308, 0.818, 16, 48, 26, 13, 9, 9, 22

When you add a list to another, you are simply adding the ENTIRE list as one item in the new list. Say you want to add all the values in tt1 to a made up list, tt2.

tt1= [102, 0.5, 0.591, 0.529, 10, 42, 26, 6, 8, 17, 24]
tt2= ["some", "other", "list", 6.5, 102, True]

for item in tt1[::-1]: # we insert backwards to make it appear forwards
    tt2.insert(2, item)

print(tt2)

It is hard to explain, but the reason why I reverse the list temporariy ([::-1]) is once an item is inserted, it actually becomes the index 2. If we insert again, the previous item will become index 3 and the new item index 2 – backwards. So I reverse the list, so we’re adding backwards and inserting backwards – backwards + backwards = forwards

Output:

["some", "other", 102, 0.5, 0.591, 10, 42, 26, 6, 8, 17, 24, "list", 6.5, 102, True]

Simply replace the tt2 with whatever list you want to add the items to.

3

solved how can i remove bracket in list with float data