Add data to new list


#1

Hi,

i had a list with "mylist"some 280 items.
i used a for loop to filter out my required items :

for data in mylist:
if ‘profile’ in data:
print(data)

and the output is:

profile/7014002.htm
profile/7016001.htm
profile/7001004.htm
profile/7013004.htm
profile/7010001.htm
profile/7016002.htm
profile/7001006.htm
profile/7016004.htm
profile/7013044.htm
profile/7013035.htm
profile/7013001.htm
profile/7007014.htm
profile/7001041.htm
profile/7010046.htm
profile/7016034.htm
profile/7010045.htm
profile/7007053.htm
profile/7013043.htm
profile/7010043.htm
profile/5995054.htm
profile/5995058.htm
profile/7001038.htm
profile/7013048.htm
profile/7013007.htm
profile/7016010.htm
profile/7010009.htm
profile/7013006.htm
profile/7013010.htm
profile/7010005.htm
profile/7007007.htm
profile/7013008.htm
profile/7007009.htm
profile/7010008.htm
profile/7007010.htm
profile/7010010.htm
profile/7016021.htm
profile/7010021.htm
profile/7010020.htm
profile/7013016.htm
profile/7013019.htm
profile/7013021.htm
profile/5995030.htm
profile/7016017.htm
profile/7013022.htm
profile/7013049.htm
profile/7007054.htm
profile/7007058.htm
profile/7007059.htm
profile/7016035.htm
profile/7004057.htm
profile/7004056.htm
profile/7001046.htm
profile/7010048.htm
profile/7013051.htm
profile/7016039.htm
profile/7013052.htm
profile/7013053.htm
profile/7010050.htm
profile/5993006.htm
profile/7004059.htm
profile/7007061.htm
profile/7013055.htm
profile/7016040.htm
profile/7013039.htm
profile/7004039.htm
profile/7013037.htm
profile/7010037.htm
profile/7016030.htm

but i like to put them in a new list, i am not sure how to do that


#2

you can simply create a new list and use append() to append to list? Its super simple, please google and do some basic research before asking such a simple question.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.