I have:
count = 0 i = 0 while count < len(mylist): if mylist[i + 1] == mylist[i + 13] and mylist[i + 2] == mylist[i + 14]: print mylist[i + 1], mylist[i + 2] newlist.append(mylist[i + 1]) newlist.append(mylist[i + 2]) newlist.append(mylist[i + 7]) newlist.append(mylist[i + 8]) newlist.append(mylist[i + 9]) newlist.append(mylist[i + 10]) newlist.append(mylist[i + 13]) newlist.append(mylist[i + 14]) newlist.append(mylist[i + 19]) newlist.append(mylist[i + 20]) newlist.append(mylist[i + 21]) newlist.append(mylist[i + 22]) count = count + 1 i = i + 12
I wanted to make the newlist.append() statements into a few statements.
newlist.append()
No. The method for appending an entire sequence is list.extend().
list.extend()
>>> L = [1, 2] >>> L.extend((3, 4, 5)) >>> L [1, 2, 3, 4, 5]
1.4m articles
1.4m replys
5 comments
57.0k users