python add to each element in list code example
Example 1: add 1 to all elements in list python
lst = [1,2,3]
list(map(lambda x:x+1, lst))
Example 2: add a string to each element of a list python
my_list = ['foo', 'fob', 'faz', 'funk']
string = 'bar'
list2 = list(map(lambda orig_string: orig_string + string, my_list))
Example 3: add an element to list python
a=[8,5,6,1,7]
a.append(9)