Playgrounds
Snippets
Developers
Compiler
All
ActionScript
Ajax
AngularJS
Apache
AppleScript
ASP.NET
Bash
C
C#
C++
Coffee
CoffeeScript
ColdFusion
Command
CSS
Delphi
Django
ES6
GLSL
Grunt
Gulp
HAML
Haskell
HTML
iOS
Jade
Java
JavaScript
jQuery
JSX
Less
LUA
MDX
MySQL
Objective
Other
Pascal
Perl
PHP
Plain text
PowerShell
Processing
Progress
Prolog
Pseudocode
Python
Rails
RegExr
Ruby
SASS
Scala
Scheme
SCSS
SmallBASIC
Smarty
SQL
Stylus
SVG
Swift
TypeScript
VHDL
X++
XHTML
XML
Xojo
XSLT
New snippet
New playground
Sign up
Login
Upload
Playgrounds
Snippets
Developers
Sign up
Login
Takes a list of integers as input and returns the product of all of the elements in the list
Python
by
Cesar Augusto Nogueira
22nd September 2016
1
2
def
product
(
listIntegers
)
:
totalProduct
=
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
latest revision
2
1
This function takes a list of integers as input and returns the product of all of the elements in the list.
2 Responses
Try to call reduce(lambda x, y: x*y, [1, 2, 3]). Using built-in functions is more pythonic way.
0
Reply?
Sergey Olerinskiy
8 years ago
@Sergey Olerinskiy
Thanks for the hint Sergey!
0
Reply?
Cesar Augusto Nogueira
8 years ago
Write a comment
Send Comment
You can use [html][/html], [css][/css], [php][/php] and
more
to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.
2 Responses
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.