I am having a list as:
list_1 = ['id', 'name', 'organization', 'notes', 'key_length',
'digest', 'validity_start', 'validity_end', 'country_code',
'state', 'city', 'organization_name', 'organizational_unit_name',
'email', 'common_name', 'extensions', 'serial_number', 'passphrase',
'created', 'modified']
Now, I am trying to code a list comprehension to get the below list as a final result:
list_2 = ['id', 'name', 'organization', 'notes',
'key_length', 'digest', 'validity_start', 'validity_end',
'country_code', 'state', 'city', 'organization_name', 'organizational_unit_name',
'email', 'common_name', 'serial_number', 'certificate',
'private_key', 'created', 'modified']
Here's what I am doing:
list_2 = [
field
for field in list_1
if field not in {'extensions', 'passphrase'}
]
With the above LOC I am able to get the the desired list except the two fields certificate
, & private_key
.
For that presently I am using the insert method, but I want this to be done in the the list comprehension itself.