I am new to python and linux and to programming in general, sorry for noob questions.
I have a list of cifs shares as below,
['Type', 'Sharename', 'Comment']
[['Disk', '3tb', ''], ['Disk', 'c$', 'Default share']]
I would like to remove all the shares which have a comment same as in the list below,
['Remote Admin', 'Default share', 'Remote IPC']
I wrote the below piece of code that works pretty well but I have to keep calling list = list.copy()
. It seems I am missing something here. Is this the right way to do this or is there a better way for the same and it eludes me ?
for skip in self.skip_shares_disc:
# print("Skip: " + skip)
for share in all_shares:
all_shares = all_shares.copy()
# print(" share[2]: " + share[2] + "drive: " + share[1])
if str(share[2]).upper() == str(skip).upper():
all_shares = all_shares.copy()
# print(" share[2]: " + share[2] + "drive: " + share[1])
all_shares.remove(share)
all_shares = all_shares.copy()