1def no_it_isnt(my_list):
2 """Return the opposite of each element in the list."""
3 result = []
4 for element in my_list:
5 if type(element) == str:
6 result.append(element[::-1])
7 elif type(element) == bool:
8 result.append(not element)
9 elif type(element) in (int, float):
10 result.append(element * -1)
11 return result[::-1]
.....
----------------------------------------------------------------------
Ran 5 tests in 0.000s
OK
f | 1 | def no_it_isnt(my_list): | f | 1 | def no_it_isnt(my_list): |
n | 2 | '''Return the "opposite" of each element in the list.''' | n | 2 | """Return the opposite of each element in the list.""" |
3 | result = [] | 3 | result = [] | ||
4 | for element in my_list: | 4 | for element in my_list: | ||
5 | if type(element) == str: | 5 | if type(element) == str: | ||
6 | result.append(element[::-1]) | 6 | result.append(element[::-1]) | ||
7 | elif type(element) == bool: | 7 | elif type(element) == bool: | ||
8 | result.append(not element) | 8 | result.append(not element) | ||
t | 9 | elif type(element) == int or type(element) == float: | t | 9 | elif type(element) in (int, float): |
10 | result.append(element * -1) | 10 | result.append(element * -1) | ||
11 | return result[::-1] | 11 | return result[::-1] |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|