Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Python map() and lambda #8

Copy link
Copy link
@igoose1

Description

@igoose1
Issue body actions

<pre><code class="language-python">original_list = [1, 2, 3]
new_list = [x * 2 for x in original_list]
# 2
# 4
# 6
for x in new_list:
print(x)
</code></pre>

In python there is an easier way to multiple each element in list:

original_list = [1, 2, 3]

new_list = list(map(lambda x: x * 2, original_list))

for x in new_list:
    print(x)

Imo, this example is more similar to js example because there is map function that exists in python too.

Unfortunately my example is difficult for understanding but we can split it for more lines:

original_list = [1, 2, 3]

f = lambda x: x * 2
new_list = list(map(f, original_list))

for x in new_list:
    print(x)

Thank you for your repository! I'm glad to meet it in github's recommendations! 👍

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.