[Tutor] removing items from list

marcus.luetolf at bluewin.ch marcus.luetolf at bluewin.ch
Mon Feb 7 04:21:45 EST 2022


Hello Experts,

of a list of n items at each of n iterations one other item should be
removed.

The result should yield n lists consisting of n-1 items.

Even using a copy oft he list  the indexing got mixed up.  

 

My last attempt:

 

all_items = ['item1 ','item2 ', item3 ',' item4 ', 'item5 ','item6 ',
'item7', 'item8', 'item9', 'item10 ']

 

copy_all_items = ['item1 ','item2 ', item3 ',' item4 ', 'item5 ','item6 ',
'item7', 'item8', 'item9', 'item10 ']

 

for player in all_items:

    if item in all_items:    

        c_all_items.remove(item)

        c_all_items = all_items

        print(item, c_all_items)

 

I'dappreciate to learn my mistake, thank you.



More information about the Tutor mailing list