add to every element list python code example
Example 1: how to add a number to every element in a list python
new_list = [x+1 for x in my_list]
Example 2: python add all elements of a list
lst = []num = int(input('How many numbers: '))for n in range(num): numbers = int(input('Enter number ')) lst.append(numbers)print("Sum of elements in given list is :", sum(lst))