In the following code, i am computing nums.index() twice.
if ((elem in nums) and i != nums.index(elem)):
     j = nums.index(elem)
     return i,j
Is there a way through which I can initialize the variable in the expression itself and use it in the scope of the if condition? Maybe something like this
if ((elem in nums) and i != (j = nums.index(elem))):
   return i,j
 
    