-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths05_e0064.py
More file actions
26 lines (22 loc) · 757 Bytes
/
s05_e0064.py
File metadata and controls
26 lines (22 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 19 21:26:32 2022
@author: Luke
Create a function to multiply all of the values in a list by the amount of values in the given list.
Examples
MultiplyByLength([2, 3, 1, 0]) ➞ [8, 12, 4, 0]
MultiplyByLength([4, 1, 1]) ➞ ([12, 3, 3])
MultiplyByLength([1, 0, 3, 3, 7, 2, 1]) ➞ [7, 0, 21, 21, 49, 14, 7]
MultiplyByLength([0]) ➞ ([0])
Notes
All of the values given are numbers.
All lists will have at least one element.
Don't forget to return the result.
"""
def MultiplyByLength(arr):
return [i*len(arr) for i in arr]
print(MultiplyByLength([2,3,1,0]))
print(MultiplyByLength([4,1,1]))
print(MultiplyByLength([1,0,3,3,7,2,1]))
print(MultiplyByLength([0]))
print(MultiplyByLength([1337,420,69,13]))