How to create lambda function inside a list in Python

0 votes

Hi Guys,

I am new in Python. I want to create one lambda function inside one list. How can I do that?

Jun 25, 2020 in Python by akhtar
• 38,230 points
455 views

1 answer to this question.

0 votes

Hi@akhtar,

The lambda statement can appear in places where the def is not allowed. I have attached one example for your reference.

alist = [lambda m:m**2, lambda m,n:m*n, lambda m:m**4]
print(alist[0](10), alist[1](2, 20), alist[2](3))

I hope this will give you some ideas.

answered Jun 25, 2020 by MD
• 95,440 points

Related Questions In Python

0 votes
1 answer

How to create a function like f(y) = xy^2 in Python?

This is very easy. have a look ...READ MORE

answered Aug 5, 2019 in Python by Neel
• 3,020 points

edited Aug 6, 2019 by Kalgi 1,725 views
0 votes
1 answer

How to Print a List in Python

ou are using Python 2.x syntax with ...READ MORE

answered Aug 31, 2018 in Python by charlie_brown
• 7,720 points
761 views
0 votes
1 answer

How to Reverse a list in Python

You can use the reversed function in ...READ MORE

answered Sep 29, 2018 in Python by SDeb
• 13,300 points
637 views
0 votes
1 answer

List comprehension on a nested list - How to do it in Python?

Not sure what your desired output is, ...READ MORE

answered Nov 21, 2018 in Python by Nymeria
• 3,560 points
1,238 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to call a function from another file in Python?

Hi@akhtar, You can use the import keyword to ...READ MORE

answered Jun 24, 2020 in Python by MD
• 95,440 points
4,824 views
0 votes
1 answer

How to save one list in a text file in Python?

Hi@akhtar, There is no inbuilt function available to ...READ MORE

answered Jun 25, 2020 in Python by MD
• 95,440 points
3,375 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP