Write a function named compute below that:
- Returns the square of any number for integer or floating type values
- Returns the reverse of the content if it is a string
Or returns the value None (not the string 'None') if it is another kind of value.>> I have problem with this one, not sure how to return None?
def compute(value): if type(value) == int or type(value) == float: x = value **2 if type(value) == str: x = value[::-1] else: return None return x compute(['x'])
Also, how can I use map function to return the values as a list (not a map_object) in ONE single line?
for example to return something from:
map_compute(['crew', '321', 12, ['x'], True])
to :
['werc', '123', 144, None, None]