multiply every Nth index by M | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

multiply every Nth index by M

# Get our input from the command line import sys M= int(sys.argv[2]) N= int(sys.argv[3]) # convert strings to integers numbers= sys.argv[1].split(',') for i in range(0, len(numbers)): numbers[i]= int(numbers[i]) # Your code goes here above is the starter code.. what i need to do is.. We are passing in 3 inputs. a list of numbers a multiplier value, M a value, N You should multiply every Nth element (do not multiply the 0th element) by M. So, if N is 3, you start with the 3rd element, which is index 2. If there are less than N elements then you should output the unchanged input list. can someone help me?

28th Jan 2018, 12:39 AM
Jonathan Cross
Jonathan Cross - avatar
1 Answer
+ 7
You may take a look on the map function provided by Python. 😉
28th Jan 2018, 10:17 AM
Zephyr Koo
Zephyr Koo - avatar