I want to multiply each element in a list by a given number.
For example, when I key in the following on the command prompt:
C:\Users\bella\projects\testing1> test.py 5,10,15,20,25,30 2
The result should be: [10,20,30,40,50,60]
(Note: each element is multiplied by 2)
or
C:\Users\bella\projects\testing1> test.py 5,10,15,20,25,30 0.5
The result should be: [2.5,5,7.5,10,12.5,15]
(Note: each element is multiplied by 0.5)
Here is my code...
import sys
user_input = sys.argv[1]
u_split = user_input.split(",")
option = sys.argv[2]
n = map(lambda x:x*(option), user_input)
print(n)
This is what I get on the command prompt:
C:\Users\bella\projects\testing1> test.py 10,20,30,40,50,60 2
<map object at 0x03588160>