1def no_it_isnt(data):
2 reverse_list = []
3 for x in data:
4 if type(x) in (int, float):
5 reverse_list.append(-x)
6 elif type(x) == bool:
7 reverse_list.append(not x)
8 elif type(x) == str:
9 reverse_list.append(x [::-1])
10 reverse_list.reverse()
11 return reverse_list
12
13print(no_it_isnt([1, -3.14, True, 'abc', 0])) # [0, 'cba', False, 3.14, -1]
[0, 'cba', False, 3.14, -1]
.....
----------------------------------------------------------------------
Ran 5 tests in 0.000s
OK
n | 1 | def no_it_isnt(list): | n | 1 | def no_it_isnt(data): |
2 | reverse_list = [] | 2 | reverse_list = [] | ||
n | 3 | for x in list: | n | 3 | for x in data: |
4 | if(type(x) == int or type(x) == float): | 4 | if type(x) in (int, float): | ||
5 | reverse_list.append(-x) | 5 | reverse_list.append(-x) | ||
n | 6 | elif(type(x) == bool): | n | 6 | elif type(x) == bool: |
7 | reverse_list.append(not x) | 7 | reverse_list.append(not x) | ||
t | 8 | elif(type(x) == str): | t | 8 | elif type(x) == str: |
9 | reverse_list.append(x [::-1]) | 9 | reverse_list.append(x [::-1]) | ||
10 | reverse_list.reverse() | 10 | reverse_list.reverse() | ||
11 | return reverse_list | 11 | return reverse_list | ||
12 | 12 | ||||
13 | print(no_it_isnt([1, -3.14, True, 'abc', 0])) # [0, 'cba', False, 3.14, -1] | 13 | print(no_it_isnt([1, -3.14, True, 'abc', 0])) # [0, 'cba', False, 3.14, -1] |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|