Python map function

Python map function

Instructor-svgAl-Mamun Sarkar
Mar 25 , 2020

Using map function in the python programming language. 

my_list = [2, 3, 4, 5, 6, 7]


def square(x):
    return x * x


new_list = map(square, my_list)
print(new_list)
print(list(new_list))

 

Output:


[4, 9, 16, 25, 36, 49]

 

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram