how to remove more than one element from the list subject a condition
Title
Question
how to remove more than one element from the list subject to a condition
Python-3.4.3 Getting-started-with-Lists 01-02 min 0-10 sec
Answers:
you can use loop concept
<code class="plain" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;">list </code><code class="keyword" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; font-weight: bold !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">=</code> <code class="plain" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;">[</code><code class="value" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 153, 0) !important;">11</code><code class="plain" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;">, </code><code class="value" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 153, 0) !important;">5</code><code class="plain" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;">, </code><code class="value" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 153, 0) !important;">17</code><code class="plain" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;">, </code><code class="value" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 153, 0) !important;">18</code><code class="plain" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;">, </code><code class="value" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 153, 0) !important;">23</code><code class="plain" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;">, </code><code class="value" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 153, 0) !important;">50</code><code class="plain" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;">] </code>
<code class="undefined spaces" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important;"> </code>
<code class="keyword" style="background: none !important; box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; font-weight: bold !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">for</code><span style="font-size: 0.99em;"> num</span><code class="plain" style="background: none !important; box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;"> </code><code class="keyword" style="background: none !important; box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; font-weight: bold !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">in</code><span style="font-size: 0.99em;"> </span><code class="plain" style="background: none !important; box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;">list1:</code>
<code class="undefined spaces" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important;"> </code><code class="keyword" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; font-weight: bold !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">if</code> <code class="plain" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;">num </code><code class="keyword" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; font-weight: bold !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">%</code> <code class="value" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 153, 0) !important;">2</code> <code class="keyword" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; font-weight: bold !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">=</code><code class="keyword" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; font-weight: bold !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">=</code> <code class="value" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 153, 0) !important;">0</code><code class="plain" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;">: </code>
<code class="undefined spaces" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important;"> </code><code class="plain" style="box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;">list1.remove(ele) </code>
or you can use this also if you want to remove items like from 1 to 4
<code class="keyword" style="white-space: pre; box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; font-weight: bold !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">del</code><span style="color: rgba(0, 0, 0, 0.84); font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 15.0637px; white-space: pre;"> </span><code class="plain" style="white-space: pre; box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;">list[</code><code class="value" style="white-space: pre; box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 153, 0) !important;">1</code><code class="plain" style="white-space: pre; box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;">:</code><code class="value" style="white-space: pre; box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: rgb(0, 153, 0) !important;">5</code><code class="plain" style="white-space: pre; box-sizing: content-box !important; margin: 0px !important; padding: 0px !important; border: 0px !important; font-size: 0.99em !important; vertical-align: baseline !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; line-height: 1.2em !important; background: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: hidden !important; position: static !important; right: auto !important; top: auto !important; width: auto !important; direction: ltr !important; box-shadow: none !important; display: inline !important; min-height: auto !important; color: black !important;">] </code>
Login to add comment