Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

additionner liste python

>>> list = [1,2,3,4]
>>> tot = 0
>>> for i in list:
...     tot = tot + i
... 
>>> tot
10
Comment

additionner liste python

>>> list = [1,2,3,4]
>>> sum(list)
10

>>> l = ['a',1,'f',3.2,4]
>>> sum([i for i in l if isinstance(i, int) or isinstance(i, float)])
8.2
Comment

additionner liste python


>>> from operator import add
>>> list( map(add, list1, list2) )
[5, 7, 9]

Comment

PREVIOUS NEXT
Code Example
Python :: char list python 
Python :: selecting rows with specific values in pandas 
Python :: python regex true false 
Python :: python pip 
Python :: get full path of document 
Python :: what is the size of cover in facebook 
Python :: how to avoid inserting duplicate records in orm django 
Python :: qr detector 
Python :: python - convert a list column into miltiple columns 
Python :: django prevent duplicate entries 
Python :: py quick sort 
Python :: how to iterate row wise using 2d integer array in python 
Python :: pandas sub dataframe 
Python :: python split string by specific word 
Python :: check if string is python code 
Python :: discord bot python 
Python :: deploy django on nginx gunicorn 
Python :: command for python shell 
Python :: how to round whole numbers in python 
Python :: giving number of letter in python 
Python :: loading bar 
Python :: python add list 
Python :: python import function from file 
Python :: onehot encode list of columns pandas 
Python :: truncatechars django 
Python :: how to separate numeric and categorical variables in python 
Python :: tf dataset 
Python :: test pypi 
Python :: convert 12 hour into 24 hour time 
Python :: write hexadecimal in python 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =