Note that there are some explanatory texts on larger screens.

plurals
  1. POsearching a substring in a python list and then removing it from the list
    primarykey
    data
    text
    <p>I have a python list like:</p> <pre><code>['A /cloudos-ui/branches/bare_metal', 'M /cloudos-ui/branches/bare_metal/packaging/DEBIAN/control', 'M /cloudos-ui/branches/bare_metal/create_cosmos_installer.sh', 'M /cloudos-ui/branches/bare_metal/packaging/DEBIAN/control', 'M /cloudos-ui/branches/bare_metal/scripts/create_skyline_installer.sh', 'M /cloudos-ui/branches/bare_metal/forms.py', 'M /cloudos-ui/branches/bare_metal/tables.py', 'M /cloudos-ui/branches/bare_metal/templates/flavors/_create.html', 'M /cloudos-ui/branches/bare_metal/templates/flavors/_edit.html', 'A /cloudos-ui/branches/bare_metal/scripts/create_skyline_installer.sh', 'A /cloudos-ui/branches/bare_metal/forms.py', 'A /cloudos-ui/branches/bare_metal/tables.py', 'A /cloudos-ui/branches/bare_metal/templates/flavors/_create.html'] </code></pre> <p>Now the first character of each string is either <code>A</code> or <code>M</code>. Apart from this first letter, some of the strings are identical: for example the two strings ending with <code>create_skyline_installer.sh</code>, 5th from the top and 4th from the bottom.</p> <p>Now what I am trying to achieve is to find strings where after <code>A</code> or <code>M</code> the rest of the body of the string is same. Then I want to remove the list element which is starting with <code>M</code>.</p> <p>I mean the final list should look like this:</p> <pre><code>['A /cloudos-ui/branches/bare_metal', 'M /cloudos-ui/branches/bare_metal/packaging/DEBIAN/control', 'M /cloudos-ui/branches/bare_metal/create_cosmos_installer.sh', 'M /cloudos-ui/branches/bare_metal/packaging/DEBIAN/control', 'M /cloudos-ui/branches/bare_metal/scripts/create_skyline_installer.sh', 'M /cloudos-ui/branches/bare_metal/forms.py', 'M /cloudos-ui/branches/bare_metal/tables.py', 'M /cloudos-ui/branches/bare_metal/templates/flavors/_create.html', 'M /cloudos-ui/branches/bare_metal/templates/flavors/_edit.html'] </code></pre> <p>But I am unable to find a solution.</p> <p>Please help me out.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload