Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. We are passing in 3 inputs.
  2.  
  3. a list of numbers
  4. a multiplier value, M
  5. a value, N
  6. 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.
  7.  
  8. If there are less than N elements then you should output the unchanged input list.
  9. *********************************************************************************************
  10.  
  11. # Get our input from the command line
  12. import sys
  13. M= int(sys.argv[2])
  14. N= int(sys.argv[3])
  15.  
  16. # convert strings to integers
  17. numbers= sys.argv[1].split(',')
  18. for i in range(0, len(numbers)):
  19. numbers[i]= int(numbers[i])
  20.  
  21. # Your code goes here
  22. for N in numbers:
  23. if numbers[i]>0:
  24. total =N * M
  25. print(total)
  26. else:
  27. print(numbers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement