Below is an easy level coding problem, based on string manipulation:-
I was able to solve it using a for loop by defining conditions for positive and negative numbers.
But while going through other solutions, I found this interesting solution in Python for the same question.
I have been working in Python for the past year but this is my first time coming across the below syntax for if else block
if [str(x) > A[i], str(x) < A[i]][A[0] == '-']:
Below is the complete code :
def maxValue(self, A, x):
for i in xrange(len(A)):
if [str(x) > A[i], str(x) < A[i]][A[0] == '-']:
return A[:i] + str(x) + A[i:]
return A + str(x)
How can I interpret this block? Where can I find documentation for it?

[]in term position do? What does[]in postfix position do? What do booleans do when coerced toint?X if C else Ywhich is written as[Y, X][C]. Note that in this form both X and Y are evaluated which does not occur in the if expression.X if C else Yand [Y, X][C]` are functionally different when it comes to execution? First expression is much more safer then, right?