1def no_it_isnt(items):
2 result = []
3 for item in items:
4 if type(item) is str:
5 result.append(item[::-1])
6 elif type(item) in (int, float):
7 item *= (-1)
8 result.append(item)
9 elif type(item) is bool:
10 result.append(not item)
11 result.reverse()
12 return result
.....
----------------------------------------------------------------------
Ran 5 tests in 0.000s
OK
f | 1 | f | 1 | ||
2 | 2 | ||||
t | 3 | def no_it_isnt(my_list): | t | 3 | def no_it_isnt(items): |
4 | result = [] | ||||
5 | for item in items: | ||||
6 | if type(item) is str: | ||||
7 | result.append(item[::-1]) | ||||
8 | elif type(item) in (int, float): | ||||
9 | item *= (-1) | ||||
10 | result.append(item) | ||||
11 | elif type(item) is bool: | ||||
12 | result.append(not item) | ||||
4 | my_list.reverse() | 13 | result.reverse() | ||
5 | for i in range(len(my_list)): | 14 | return result | ||
6 | if type(my_list[i]) is str: | ||||
7 | my_list[i] = my_list[i][::-1] | ||||
8 | elif type(my_list[i]) is int or type(my_list[i]) is float: | ||||
9 | my_list[i] *= (-1) | ||||
10 | elif type(my_list[i]) is bool: | ||||
11 | my_list[i] = not my_list[i] | ||||
12 | return my_list |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|