1 2 3 4 5 6 7 8 9 |
<span class="cm-variable">alphabet</span> = [<span class="cm-string">"a"</span>, <span class="cm-string">"b"</span>, <span class="cm-string">"c"</span>, <span class="cm-string">"d"</span>, <span class="cm-string">"e"</span>] <span class="cm-variable">alphabet</span>[<span class="cm-number">0</span>] = <span class="cm-string">"A"</span> <span class="cm-variable">alphabet</span>[<span class="cm-number">1</span>:<span class="cm-number">3</span>] = [<span class="cm-string">"B"</span>, <span class="cm-string">"C"</span>] </code><code class="cm-s-ipython language-python"><span class="cm-builtin">print</span></code><code class="cm-s-ipython language-python">(<span class="cm-variable">alphabet</span>) </code><code class="cm-s-ipython language-python"><span class="cm-comment"># ["A", "B", "C", "d", "e"]が出力される</span></code><code class="cm-s-ipython language-python"> <span class="cm-variable">alphabet</span> = <span class="cm-variable">alphabet</span> <span class="cm-operator">+</span> [<span class="cm-string">"f"</span>] <span class="cm-variable">alphabet</span> += [<span class="cm-string">"g"</span>,<span class="cm-string">"h"</span>] <span class="cm-variable">alphabet</span>.<span class="cm-property">append</span>(<span class="cm-string">"i"</span>) <span class="cm-builtin">print</span>(<span class="cm-variable">alphabet</span>) <span class="cm-comment"># ["A", "B", "C", "d", "e", "f", "g", "h", "i"]が出力される</span> |
コメントを残す