In the func
function, I performed some processing on the oldlist[]
and then saved the result in a buffer[]
list. Now I want to save this buffer[]
list to be the first one in a list of tuples. After that, a new values in buffer[]
must be saved as a second list in tuples and so on.
The output something like this
#list of tuple:
Ltuple=[(1,2,3),(66,53,6),(3,1,5,8,3)]
I do not know how to use list of tuple any advice please?
def func(oldlist):
buffer = []
buffer.append(oldlist[0])
# some processing on the items of oldlist[]
buffer.append(oldlist[index])
print(buffer)
# Now here I need to append the buffer[] in list of tuple to be the
# first list in tuple and in next time the new list insert to be
# the second list in list of tuple
buffer.clear()
oldlist=[]
#Some code to deal with oldlist[] and in each time send some items
# from oldlist[] to func()
func(oldlist)
oldlist.clear()
question from:
https://stackoverflow.com/questions/65875616/how-to-write-multi-list-in-list-of-tuple 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…