Python Online Compiler & Playground
HTML/CSS/JavaScript
HTML
CSS
Javascript
C++
C
PHP
Java
Python
Swift
C#
Ruby
Node.JS
Kotlin
jQuery
Go
R
TypeScript
Start Python Course
Register
Reduce with comprehension experiment
+3
Author: Tibor Santa
Dark
Public
Save
PY
py
1
2
3
4
5
6
7
8
9
10
# implementing reduce with comprehension
# (this is ugly as hell)
def
global_add
(
n
):
global
total
total += n
total =
0
[
global_add
(
x
)
for
x
in
range
(
10
)]
print
(
total
)
Enter to Rename, Shift+Enter to Preview
OUTPUT