0

I am trying to construct a function called maxSquare. In which it takes a list of integers X and returns Xi with the maximum square value, without using loops.

Sample Input/Output

>>> maxSquare([5, ‐7, 3])
-7


If you coul help me with this, I would appreciate it.

Thanks in advance.

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by pyTony
0

Consider how could you do it with key argument There is one built in function, which puts numbers in same order as square, so even you do not need lambda or def.

Edited by pyTony: n/a

0

Consider how could you do it with key argument There is one built in function, which puts numbers in same order as square, so even you do not need lambda or def.

This is what I have done

import operator 
   return (max(map(lambda x:operator.pow(x, 2), [5,-7,3])))

I am almost there, but how can I return the original value which is -7 ?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.