Issue
Define a function that accepts a list (called numbers below) as input and return a list where each element is multiplied by 10. The grader will supply the argument numbers to the function when you run the grader.score.in__problem2 method below.
In this case, you need to write a function that will work for arbitrary input. Before submitting your function to the grader, you may want to check that it returns the output that you expect by evaluating code similar to the following:
test_numbers = [1, 2, 3]
mult(test_numbers)
I am relatively new to coding and i am finding it hard to come up with a proper solution
def mult(numbers):
return (10) * len(numbers)
i expect output to be (10, 20, 30)
but i only get 30 as a response
Solution
You can use list comprehension:
def mult(my_list):
return [10*n for n in my_list]
>>> m = [1,2,3]
>>> mult(m)
[10,20,30]
Answered By - blackbrandt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.