J P
0
Q:

python multiply list

# Python program to multiply all values in the 
# list using traversal 
#IF NOT USING NUMPY
def multiplyList(myList) : 
      
    # Multiply elements one by one 
    result = 1
    for x in myList: 
         result = result * x  
    return result  
      
# Driver code 
list1 = [1, 2, 3]  
list2 = [3, 2, 4] 
print(multiplyList(list1)) 
print(multiplyList(list2)) 
3
a_list = [1, 2, 3]

a_list = [item * 2 for item in a_list]

print(a_list)
OUTPUT
[2, 4, 6]
1

New to Communities?

Join the community