Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <section id="nice" data-tool="markdown编辑器" data-website="https://markdown.com.cn/editor" style="font-size: 16px; color: black; padding: 25px 30px; line-height: 1.6; word-spacing: 0px; letter-spacing: 0px; word-break: break-word; word-wrap: break-word; text-align: justify; font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif; margin-top: -10px;"><pre class="custom" data-tool="markdown.com.cn编辑器" style="margin-top: 10px; margin-bottom: 10px;"><code class="hljs" style="overflow-x: auto; padding: 16px; color: #383a42; background: #fafafa; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; -webkit-overflow-scrolling: touch;"><span class="hljs-function" style="line-height: 26px;"><span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">def</span> <span class="hljs-title" style="color: #4078f2; line-height: 26px;">transpose</span><span class="hljs-params" style="line-height: 26px;">(lst)</span>:</span><br> <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">return</span> list(zip(*lst))<br><br><span class="hljs-comment" style="color: #a0a1a7; font-style: italic; line-height: 26px;"># EXAMPLES</span><br>transpose([[<span class="hljs-number" style="color: #986801; line-height: 26px;">1</span>, <span class="hljs-number" style="color: #986801; line-height: 26px;">2</span>, <span class="hljs-number" style="color: #986801; line-height: 26px;">3</span>], [<span class="hljs-number" style="color: #986801; line-height: 26px;">4</span>, <span class="hljs-number" style="color: #986801; line-height: 26px;">5</span>, <span class="hljs-number" style="color: #986801; line-height: 26px;">6</span>], [<span class="hljs-number" style="color: #986801; line-height: 26px;">7</span>, <span class="hljs-number" style="color: #986801; line-height: 26px;">8</span>, <span class="hljs-number" style="color: #986801; line-height: 26px;">9</span>], [<span class="hljs-number" style="color: #986801; line-height: 26px;">10</span>, <span class="hljs-number" style="color: #986801; line-height: 26px;">11</span>, <span class="hljs-number" style="color: #986801; line-height: 26px;">12</span>]]) <span class="hljs-comment" style="color: #a0a1a7; font-style: italic; line-height: 26px;"># [(1, 4, 7, 10), (2, 5, 8, 11), (3, 6, 9, 12)]</span><br></code></pre>
- </section>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement