1def no_it_isnt(arguments: list):
2 '''Reverse and replace arguments with their counters'''
3 result = []
4 for item in arguments[::-1]:
5 if isinstance(item, bool):
6 result.append(not(item))
7 elif isinstance(item, int) or isinstance(item, float):
8 result.append(-item)
9 elif isinstance(item, str):
10 result.append(item[::-1])
11 else:
12 print(f"Cannot handle {type(item)} type for {item}")
13
14 return result
15
16print(no_it_isnt([1, -3.14, True, 'abc', 0, (1, 2)]))
17
18# Cannot handle <class 'tuple'> type for (1, 2)
19# [0, 'cba', False, 3.14, -1]
Cannot handle <class 'tuple'> type for (1, 2)
[0, 'cba', False, 3.14, -1]
.....
----------------------------------------------------------------------
Ran 5 tests in 0.000s
OK
| f | 1 | def no_it_isnt(arguments: list): | f | 1 | def no_it_isnt(arguments: list): |
| n | 2 | '''Do work''' | n | 2 | '''Reverse and replace arguments with their counters''' |
| 3 | result = [] | 3 | result = [] | ||
| 4 | for item in arguments[::-1]: | 4 | for item in arguments[::-1]: | ||
| n | 5 | if (isinstance(item, bool)): | n | 5 | if isinstance(item, bool): |
| 6 | result.append(not(item)) | 6 | result.append(not(item)) | ||
| n | 7 | elif (isinstance(item, int) or isinstance(item, float)): | n | 7 | elif isinstance(item, int) or isinstance(item, float): |
| 8 | result.append(-item) | 8 | result.append(-item) | ||
| n | 9 | elif (isinstance(item, str)): | n | 9 | elif isinstance(item, str): |
| 10 | result.append(item[::-1]) | 10 | result.append(item[::-1]) | ||
| 11 | else: | 11 | else: | ||
| 12 | print(f"Cannot handle {type(item)} type for {item}") | 12 | print(f"Cannot handle {type(item)} type for {item}") | ||
| 13 | 13 | ||||
| 14 | return result | 14 | return result | ||
| 15 | 15 | ||||
| t | 16 | # print(no_it_isnt([1, -3.14, True, 'abc', 0, (1, 2)])) | t | 16 | print(no_it_isnt([1, -3.14, True, 'abc', 0, (1, 2)])) |
| 17 | 17 | ||||
| 18 | # Cannot handle <class 'tuple'> type for (1, 2) | 18 | # Cannot handle <class 'tuple'> type for (1, 2) | ||
| 19 | # [0, 'cba', False, 3.14, -1] | 19 | # [0, 'cba', False, 3.14, -1] |
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||
| f | 1 | def no_it_isnt(arguments: list): | f | 1 | def no_it_isnt(arguments: list): |
| n | n | 2 | '''Do work''' | ||
| 2 | result = [] | 3 | result = [] | ||
| 3 | for item in arguments[::-1]: | 4 | for item in arguments[::-1]: | ||
| 4 | if (isinstance(item, bool)): | 5 | if (isinstance(item, bool)): | ||
| 5 | result.append(not(item)) | 6 | result.append(not(item)) | ||
| 6 | elif (isinstance(item, int) or isinstance(item, float)): | 7 | elif (isinstance(item, int) or isinstance(item, float)): | ||
| 7 | result.append(-item) | 8 | result.append(-item) | ||
| 8 | elif (isinstance(item, str)): | 9 | elif (isinstance(item, str)): | ||
| 9 | result.append(item[::-1]) | 10 | result.append(item[::-1]) | ||
| 10 | else: | 11 | else: | ||
| 11 | print(f"Cannot handle {type(item)} type for {item}") | 12 | print(f"Cannot handle {type(item)} type for {item}") | ||
| 12 | 13 | ||||
| 13 | return result | 14 | return result | ||
| 14 | 15 | ||||
| t | 15 | print(no_it_isnt([1, -3.14, True, 'abc', 0, (1, 2)])) | t | 16 | # print(no_it_isnt([1, -3.14, True, 'abc', 0, (1, 2)])) |
| 17 | |||||
| 18 | # Cannot handle <class 'tuple'> type for (1, 2) | ||||
| 19 | # [0, 'cba', False, 3.14, -1] |
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||