Possible Duplicate:
Ternary conditional operator in Python
I want to do the following in python:
while( i < someW && j < someX){
int x = A[i] > B[j]? A[i++]:B[j++];
....
}
Clearly, when either i or j hits a limit, the code will break out of the loop. I need the values of i and j outside of the loop.
Must I really do
x=0
...
if A[i] > B[j]:
x = A[i]
i+=1
else:
x = B[j]
j+=1
Or does anyone know of a shorter way?
Besides the above, can I get Python to support something similar to
a,b=5,7
x = a > b ? 10 : 11