1def no_it_isnt(my_list):
2 new_list = []
3 for item in my_list:
4 if isinstance(item, str):
5 new_list.append(item[::-1])
6 elif isinstance(item, bool):
7 new_list.append(not item)
8 else:
9 new_list.append(-item)
10 return new_list[::-1]
.....
----------------------------------------------------------------------
Ran 5 tests in 0.000s
OK
f | 1 | def no_it_isnt(my_list): | f | 1 | def no_it_isnt(my_list): |
2 | new_list = [] | 2 | new_list = [] | ||
n | 3 | i = 0 | n | 3 | for item in my_list: |
4 | for i in range(len(my_list)): | ||||
5 | if isinstance(my_list[i], str): | 4 | if isinstance(item, str): | ||
6 | new_list.append(my_list[i][::-1]) | 5 | new_list.append(item[::-1]) | ||
7 | elif isinstance(my_list[i], bool): | 6 | elif isinstance(item, bool): | ||
8 | if my_list[i]: | ||||
9 | new_list.append(False) | ||||
10 | else: | ||||
11 | new_list.append(True) | 7 | new_list.append(not item) | ||
12 | else: | 8 | else: | ||
t | 13 | new_list.append(-my_list[i]) | t | 9 | new_list.append(-item) |
14 | return new_list[::-1] | 10 | return new_list[::-1] |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | def no_it_isnt(my_list): | f | 1 | def no_it_isnt(my_list): |
2 | new_list = [] | 2 | new_list = [] | ||
3 | i = 0 | 3 | i = 0 | ||
4 | for i in range(len(my_list)): | 4 | for i in range(len(my_list)): | ||
5 | if isinstance(my_list[i], str): | 5 | if isinstance(my_list[i], str): | ||
6 | new_list.append(my_list[i][::-1]) | 6 | new_list.append(my_list[i][::-1]) | ||
7 | elif isinstance(my_list[i], bool): | 7 | elif isinstance(my_list[i], bool): | ||
8 | if my_list[i]: | 8 | if my_list[i]: | ||
9 | new_list.append(False) | 9 | new_list.append(False) | ||
10 | else: | 10 | else: | ||
11 | new_list.append(True) | 11 | new_list.append(True) | ||
12 | else: | 12 | else: | ||
13 | new_list.append(-my_list[i]) | 13 | new_list.append(-my_list[i]) | ||
14 | return new_list[::-1] | 14 | return new_list[::-1] | ||
t | 15 | list1 = [1, -3.14, True, 'abc', 0] | t | ||
16 | print(no_it_isnt(list1)) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|