Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python [a]*b means [a,a,...b times] v2

>>> [1, 2, 3] * 3
[1, 2, 3, 1, 2, 3, 1, 2, 3]
Comment

python [a]*b means [a,a,...b times]

The [0] * x creates a list with x elements. So,
>>> [ 0 ] * 5
   gives [0,0,0,0,0]

******** warn:they all point to the same object.
This is cool for immutables like integers but a pain for things like lists.
>>> t = [[]] * 5
>>> t
[[], [], [], [], []]
>>> t[0].append(5)
>>> t
[[5], [5], [5], [5], [5]]
>>> 
Comment

PREVIOUS NEXT
Code Example
Python :: how to record the steps of mouse and play the steps using python 
Python :: how to find index of second largest number in array python 
Python :: how to find duplicate numbers in list in python 
Python :: scoop bucket add extras 
Python :: tkinter refresh window 
Python :: Add a quit button Tkinter 
Python :: cprofile implementation 
Python :: df drop column 
Python :: delete the duplicates in python 
Python :: python dedent 
Python :: openpyxl add worksheet 
Python :: say command python 
Python :: pandas conditional replace values in a series 
Python :: import statsmodels.api as sm 
Python :: reverse string in python 
Python :: Incorrect number of bindings supplied. The current statement uses 1, and there are 3 supplied. 
Python :: python dataclass default factory 
Python :: python voice recognition 
Python :: add headers tp requests python 
Python :: connect flask with postgresql 
Python :: what is a cube minus b cube 
Python :: format percentage python 
Python :: python get random character from string 
Python :: Get all the categorical column from the dataframe using python 
Python :: numpy create a matrix of certain value 
Python :: python iterar diccionario 
Python :: how to copy one dictionary to another in python 
Python :: convert video to text python 
Python :: auto python to exe 
Python :: scrfoll with selenium python 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =