1def no_it_isnt(arr):
2 new_arr = []
3
4 for item in reversed(arr):
5 if type(item) in (int, float):
6 new_arr.append(-item)
7 elif type(item) == bool:
8 new_arr.append(not item)
9 elif type(item) == str:
10 new_arr.append(''.join(reversed(item)))
11 return new_arr
.....
----------------------------------------------------------------------
Ran 5 tests in 0.000s
OK
f | 1 | def no_it_isnt(arr): | f | 1 | def no_it_isnt(arr): |
2 | new_arr = [] | 2 | new_arr = [] | ||
n | 3 | i = 0 | n | ||
4 | 3 | ||||
5 | for item in reversed(arr): | 4 | for item in reversed(arr): | ||
n | 6 | if type(item) == int or type(item) == float: | n | 5 | if type(item) in (int, float): |
7 | if item != 0: | ||||
8 | new_arr.append(-item) | 6 | new_arr.append(-item) | ||
9 | i += 1 | ||||
10 | else: | ||||
11 | new_arr.append(0) | ||||
12 | i += 1 | ||||
13 | elif type(item) == bool: | 7 | elif type(item) == bool: | ||
14 | new_arr.append(not item) | 8 | new_arr.append(not item) | ||
n | 15 | i +=1 | n | ||
16 | elif type(item) == str: | 9 | elif type(item) == str: | ||
t | 17 | new_arr.append(''.join(reversed(item))) | t | 10 | new_arr.append(''.join(reversed(item))) |
18 | i += 1 | ||||
19 | |||||
20 | return new_arr | 11 | return new_arr |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|