Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

add a constant to a list python

>>> L = [1]*5
>>> [x+1 for x in L]
[2, 2, 2, 2, 2]
>>>
Comment

add a constant to a list python


import numpy
a = [1, 1, 1 ,1, 1]
ar = numpy.array(a)
print ar + 2

Comment

PREVIOUS NEXT
Code Example
Python :: guessing game python 
Python :: python increment 
Python :: python print set 
Python :: pandas order dataframe by column of other dataframe 
Python :: python how to use rnage 
Python :: primes python 
Python :: lower and upper case user input python 
Python :: python int in list 
Python :: created by and updated by in django 
Python :: TypeError: method() takes 1 positional argument but 2 were given 
Python :: astype float across columns pandas 
Python :: python list intersection 
Python :: python dictionary add item 
Python :: how to run python code in python 
Python :: expand pandas dataframe into separate rows 
Python :: pandas using eval converter excluding nans 
Python :: python tkinter 
Python :: create a dictionary from index and column pandas 
Python :: panda lambda function returns dataframe 
Python :: python regex split 
Python :: quicksort algorithm in python 
Python :: python program to calculate the average of numbers in a given list 
Python :: anonymous function python 
Python :: get_permissions 
Python :: Python NumPy expand_dims Function Example 
Python :: format when turning float into string 
Python :: python list comprehensions 
Python :: get array from h5py dataset 
Python :: how to read specific words from a file in python 
Python :: how to access pandas column 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =