1def no_it_isnt(list_of_values):
2 result_list = []
3 reversed_list_of_values = reversed(list_of_values)
4
5 for i in reversed_list_of_values:
6 if isinstance(i, bool):
7 result_list.append(not i)
8 elif isinstance(i,(int, float)):
9 result_list.append(- i)
10 elif isinstance(i, str):
11 result_list.append(i[:: -1])
12
13 return result_list
14
15# print(no_it_isnt([1, -3.14, True, 'abc', 0]))
.....
----------------------------------------------------------------------
Ran 5 tests in 0.000s
OK
n | 1 | def no_it_isnt(list): | n | 1 | def no_it_isnt(list_of_values): |
2 | reversed_list = [] | 2 | result_list = [] | ||
3 | list.reverse() | 3 | reversed_list_of_values = reversed(list_of_values) | ||
4 | 4 | ||||
n | 5 | for i in list: | n | 5 | for i in reversed_list_of_values: |
6 | if isinstance(i, bool): | 6 | if isinstance(i, bool): | ||
n | 7 | reversed_list.append(not i) | n | 7 | result_list.append(not i) |
8 | elif isinstance(i,(int, float)): | 8 | elif isinstance(i,(int, float)): | ||
n | 9 | reversed_list.append(- i) | n | 9 | result_list.append(- i) |
10 | elif isinstance(i, str): | 10 | elif isinstance(i, str): | ||
n | 11 | reversed_list.append(i[:: -1]) | n | 11 | result_list.append(i[:: -1]) |
12 | 12 | ||||
t | 13 | return reversed_list | t | 13 | return result_list |
14 | 14 | ||||
15 | # print(no_it_isnt([1, -3.14, True, 'abc', 0])) | 15 | # print(no_it_isnt([1, -3.14, True, 'abc', 0])) | ||
16 | 16 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|