i want after end second for-loop the create new list, in other words when j increment define new list
the code is:
for j in range(0, countOfAtt):
for i in range(j, len(content3), countOfAtt):
list1.append(content3[i])
thank you in advance
Does this work?
final_list = [] # this will hold all the lists you created in for loop
for j in range(0, countOfAtt):
mylist = [] # initiate a new list
for i in range(j, len(content3), countOfAtt):
mylist.append(content3[i])
final_list.append(mylist)
This will give you a new list (with whatever you were trying to put in it) for every j
:
[[content3[i] for i in range(j, len(content3), countOfAtt)] for j in range(countOfAtt)]
If it doesn't give you what you want, then you'll have to show samples of the data you have before the loops, and of the output you desire, so we could check the logic.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.