Define a function that accepts a list (called numbers below) as input and return a list where each element is multiplied by 10. 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)
any help?
Simple solution using the list comprehension.
def multiply(lis):
return [x * 10 for x in list]
This worked for me
def multiply(input_list):
return map(lambda a: a*10, input_list)
inp = map(int, input("Enter numbers seperated by comma(,):").split(','))
mul = multiply(inp)
for i in mul:
print(i)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.