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

Sign up
Appearance settings

Commit 32ed35b

Browse files
Merge pull request #24 from aakashdinkar/master
Create Reduce_method.md
2 parents a71f219 + a50c696 commit 32ed35b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎snippets/python/Reduce_method.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Reduce Method
2+
### The reduce() function is used to apply a particular function passed in its argument to all of the list elements mentioned in the sequence passed along.
3+
4+
_tags_: reduce
5+
6+
# Snippet
7+
```
8+
# following code will reduce a list to give a result based on particular function
9+
10+
from functools import reduce
11+
12+
list_of_numbers = [1, 2, 3, 4, 5]
13+
prod = 1
14+
15+
def multiplication(a, b):
16+
return a*b
17+
18+
result = reduce(multiplication, list_of_numbers)
19+
print(result)
20+
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /