Skip to content

Map()  #179

Open
Open
Map() #179
@Bravebirdinc

Description

@Bravebirdinc

What exactly it means and what it does?
Please explain in technical terms and in a simple language.
Thank You

Activity

Aneousion

Aneousion commented on Jan 1, 2023

@Aneousion

It is used for applying a function to an iterable object like a list, string or tuple. It takes the function and 1 or more iterable as arguments.
e.g.
`
def add_one(x):
return x+1

i = [1,2,3]

print(list(map(add_one,i)))

THIS PRINTS [2, 3, 4]

Two iterables
def add_both(x, y):
return x + y

first = [2, 3, 4]
second = [1, 2, 3]

print(list(map(add_both, first, second)))

THIS PRINTS [3, 5, 7]

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      Map() · Issue #179 · zhiwehu/Python-programming-exercises